Files
constructdemo/ConstructorAppApi/Controllers/CompanyInfoVideoController.cs
2025-05-01 15:18:30 +03:00

63 lines
2.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AutoMapper;
using ConstructorApp.BusinessLayer.Abstract;
using ConstructorApp.DtoLayer.CompanyInfoVideoDto;
using ConstructorApp.EntityLayer.Entities;
using Microsoft.AspNetCore.Mvc;
namespace ConstructorAppApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class CompanyInfoVideoController : ControllerBase
{
private readonly ICompanyInfoVideoService _companyInfoVideoService;
private readonly IMapper _mapper;
public CompanyInfoVideoController(ICompanyInfoVideoService companyInfoVideoService, IMapper mapper)
{
_companyInfoVideoService = companyInfoVideoService;
_mapper = mapper;
}
[HttpGet]
public IActionResult CompanyInfoVideoList()
{
var value = _companyInfoVideoService.TGetListAll();
var result = _mapper.Map<List<ResultCompanyInfoVideoDto>>(value);
return Ok(result);
}
[HttpDelete("{id}")]
public IActionResult DeleteCompanyInfoVideo(int id)
{
var value = _companyInfoVideoService.TGetByID(id);
if (value != null)
{
_companyInfoVideoService.TDelete(value);
return Ok("Hakkımızda Video Bilgisi Silindi");
}
return NotFound("Hakkımızda Video Bilgisi Bulunamadı");
}
[HttpPut]
public IActionResult UpdateCompanyInfoVideo(UpdateCompanyInfoVideoDto updateCompanyInfoVideoDto)
{
var value = _mapper.Map<CompanyInfoVideo>(updateCompanyInfoVideoDto);
_companyInfoVideoService.TUpdate(value);
return Ok("Hakkımızda Video Güncellendi");
}
[HttpGet("{id}")]
public IActionResult GetCompanyInfoVideo(int id)
{
var value = _companyInfoVideoService.TGetByID(id);
if (value != null)
{
var result = _mapper.Map<ResultCompanyInfoVideoDto>(value);
return Ok(result);
}
return NotFound("Hakkımızda Video Bilgisi Bulunamadı");
}
}
}