using AutoMapper; using ConstructorApp.BusinessLayer.Abstract; using ConstructorApp.DtoLayer.TeamDto; using ConstructorApp.EntityLayer.Entities; using Microsoft.AspNetCore.Mvc; namespace ConstructorAppApi.Controllers { [Route("api/[controller]")] [ApiController] public class TeamController : ControllerBase { private readonly ITeamService _teamService; private readonly IMapper _mapper; public TeamController(ITeamService teamService, IMapper mapper) { _teamService = teamService; _mapper = mapper; } [HttpGet] public IActionResult TeamList() { var value = _teamService.TGetListAll(); var result = _mapper.Map>(value); return Ok(result); } [HttpPost] public IActionResult CreateTeam(CreateTeamDto createTeamDto) { var value = _mapper.Map(createTeamDto); _teamService.TAdd(value); return Ok("Team Bilgisi Eklendi"); } [HttpDelete("{id}")] public IActionResult DeleteTeam(int id) { var value = _teamService.TGetByID(id); if (value != null) { _teamService.TDelete(value); return Ok("Team Bilgisi Silindi"); } return NotFound("Team Bilgisi Bulunamadı"); } [HttpPut] public IActionResult UpdateTeam(UpdateTeamDto updateTeamDto) { var value = _mapper.Map(updateTeamDto); _teamService.TUpdate(value); return Ok("Team Alanı Güncellendi"); } [HttpGet("{id}")] public IActionResult GetTeam(int id) { var value = _teamService.TGetByID(id); if (value != null) { var result = _mapper.Map(value); return Ok(result); } return NotFound("Team Bilgisi Bulunamadı"); } } }