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

64 lines
2.0 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.CompanyInfoDto;
using ConstructorApp.EntityLayer.Entities;
using Microsoft.AspNetCore.Mvc;
namespace ConstructorAppApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class CompanyInfoController : ControllerBase
{
private readonly ICompanyInfoService _companyInfoService;
private readonly IMapper _mapper;
public CompanyInfoController(ICompanyInfoService companyInfoService, IMapper mapper)
{
_companyInfoService = companyInfoService;
_mapper = mapper;
}
[HttpGet]
public IActionResult CompanyInfoList()
{
var value = _companyInfoService.TGetListAll();
var result = _mapper.Map<List<ResultCompanyInfoDto>>(value);
return Ok(result);
}
[HttpDelete("{id}")]
public IActionResult DeleteCompanyInfo(int id)
{
var value = _companyInfoService.TGetByID(id);
if (value != null)
{
_companyInfoService.TDelete(value);
return Ok("Hakkımızda Bilgisi Silindi");
}
return NotFound("Hakkımızda Bilgisi Bulunamadı");
}
[HttpPut]
public IActionResult UpdateCompanyInfo(UpdateCompanyInfoDto updateCompanyInfoDto)
{
var value = _mapper.Map<CompanyInfo>(updateCompanyInfoDto);
_companyInfoService.TUpdate(value);
return Ok("Hakkımızda Alanı Güncellendi");
}
[HttpGet("{id}")]
public IActionResult GetCompanyInfo(int id)
{
var value = _companyInfoService.TGetByID(id);
if (value != null)
{
var result = _mapper.Map<ResultCompanyInfoDto>(value);
return Ok(result);
}
return NotFound("Hakkımızda Bilgisi Bulunamadı");
}
}
}