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

78 lines
2.3 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.ServiceDto;
using ConstructorApp.EntityLayer.Entities;
using Microsoft.AspNetCore.Mvc;
namespace ConstructorAppApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ServiceController : ControllerBase
{
private readonly IServiceService _serviceService;
private readonly IMapper _mapper;
public ServiceController(IServiceService serviceService, IMapper mapper)
{
_serviceService = serviceService;
_mapper = mapper;
}
[HttpGet]
public IActionResult ServiceList()
{
var value = _serviceService.TGetListAll();
var result = _mapper.Map<List<ResultServiceDto>>(value);
return Ok(result);
}
[HttpDelete("{id}")]
public IActionResult DeleteService(int id)
{
var value = _serviceService.TGetByID(id);
if (value != null)
{
_serviceService.TDelete(value);
return Ok("Hizmet Bilgisi Silindi");
}
return NotFound("Hizmet Bilgisi Bulunamadı");
}
[HttpPut]
public IActionResult UpdateService(UpdateServiceDto updateServiceDto)
{
var value = _mapper.Map<Service>(updateServiceDto);
_serviceService.TUpdate(value);
return Ok("Hizmet Alanı Güncellendi");
}
[HttpGet("{id}")]
public IActionResult GetService(int id)
{
var value = _serviceService.TGetByID(id);
if (value != null)
{
var result = _mapper.Map<ResultServiceDto>(value);
return Ok(result);
}
return NotFound("Hizmet Bilgisi Bulunamadı");
}
[HttpGet("ServiceStatusActive/{id}")]
public IActionResult ServiceStatusActive(int id)
{
_serviceService.TServiceStatusActive(id);
return Ok("Servis Aktif Hale Getirildi");
}
[HttpGet("ServiceStatusPassive/{id}")]
public IActionResult ServiceStatusPassive(int id)
{
_serviceService.TServiceStatusPassive(id);
return Ok("Servis Pasif Hale Getirildi");
}
}
}