/
renix
/
TravelGuide
Обзор
Документация
Войти
/
renix
/
TravelGuide
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
back/Controllers/FeedbackController.cs
59 строк
2 KB
artem777764
Tag Clean Architecture and Fixing Others
02 апр 2025, 21:48
02 апр 2025, 21:48
7a66f63
Код
Авторство
О чём код?
using System.Threading.Tasks; using back.DTOs.FeedbackDTO; using back.Extensions; using back.Interfaces; using back.Models; using back.Models.Entities; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace back.Controllers; [ApiController] [Route("feedback")] [Authorize] public class FeedbackController : ControllerBase { private readonly IFeedbackSerivce _service; public FeedbackController(IFeedbackSerivce service) { _service = service; } [HttpGet("")] public async Task<IActionResult> GetAll() { return Ok(await _service.GetAllAsync()); } [HttpGet("{id}")] public async Task<IActionResult> GetById(int id) { FeedbackDTO? feedbackDTO = await _service.GetByIdAsync(id); if (feedbackDTO == null) return NotFound(); return Ok(feedbackDTO); } [HttpPost("create")] public async Task<IActionResult> Create([FromBody] PostFeedbackDTO postfeedbackDTO) { return Ok(await _service.AddAsync(postfeedbackDTO)); } [HttpDelete("delete")] public async Task<IActionResult> Delete([FromBody] DeleteFeedbackDTO feedbackDTO) { bool isSuccessful = await _service.DeleteAsync(feedbackDTO.Id); if (!isSuccessful) return NotFound(); return NoContent(); } [HttpPut("update")] public async Task<IActionResult> Update([FromBody] FeedbackDTO feedbackDTO) { bool isSuccessful = await _service.UpdateAsync(feedbackDTO); if (!isSuccessful) return NotFound(); return NoContent(); } }