78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using AutoMapper;
|
||
using ConstructorApp.BusinessLayer.Abstract;
|
||
using ConstructorApp.DtoLayer.ProjectGalleryDto;
|
||
using ConstructorApp.EntityLayer.Entities;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
|
||
namespace ConstructorAppApi.Controllers
|
||
{
|
||
[Route("api/[controller]")]
|
||
[ApiController]
|
||
public class ProjectGalleryController : ControllerBase
|
||
{
|
||
private readonly IProjectGalleryService _projectGalleryService;
|
||
private readonly IMapper _mapper;
|
||
|
||
public ProjectGalleryController(IProjectGalleryService projectGalleryService, IMapper mapper)
|
||
{
|
||
_projectGalleryService = projectGalleryService;
|
||
_mapper = mapper;
|
||
}
|
||
|
||
[HttpGet]
|
||
public IActionResult ProjectGalleryList()
|
||
{
|
||
var value = _projectGalleryService.TGetListAll();
|
||
var result = _mapper.Map<List<ResultProjectGalleryDto>>(value);
|
||
return Ok(result);
|
||
}
|
||
|
||
[HttpPost]
|
||
public IActionResult CreateProjectGallery(CreateProjectGalleryDto createProjectGalleryDto)
|
||
{
|
||
var value = _mapper.Map<ProjectGallery>(createProjectGalleryDto);
|
||
_projectGalleryService.TAdd(value);
|
||
return Ok("Galeri Bilgisi Eklendi");
|
||
}
|
||
|
||
[HttpDelete("{id}")]
|
||
public IActionResult DeleteProjectGallery(int id)
|
||
{
|
||
var value = _projectGalleryService.TGetByID(id);
|
||
if (value != null)
|
||
{
|
||
_projectGalleryService.TDelete(value);
|
||
return Ok("Galeri Bilgisi Silindi");
|
||
}
|
||
return NotFound("Galeri Bilgisi Bulunamadı");
|
||
}
|
||
|
||
[HttpPut]
|
||
public IActionResult UpdateProjectGallery(UpdateProjectGalleryDto updateProjectGalleryDto)
|
||
{
|
||
var value = _mapper.Map<ProjectGallery>(updateProjectGalleryDto);
|
||
_projectGalleryService.TUpdate(value);
|
||
return Ok("Galeri Alanı Güncellendi");
|
||
}
|
||
|
||
[HttpGet("{id}")]
|
||
public IActionResult GetProjectGallery(int id)
|
||
{
|
||
var value = _projectGalleryService.TGetByID(id);
|
||
if (value != null)
|
||
{
|
||
var result = _mapper.Map<ResultProjectGalleryDto>(value);
|
||
return Ok(result);
|
||
}
|
||
return NotFound("Galeri Bilgisi Bulunamadı");
|
||
}
|
||
|
||
[HttpGet("GetByProjectId/{projectId}")]
|
||
public IActionResult GetImagesByProjectId(int projectId)
|
||
{
|
||
var images = _projectGalleryService.TGetImagesByProjectId(projectId);
|
||
return Ok(images);
|
||
}
|
||
}
|
||
}
|