/
h0tnanny
/
DeliveryService
Обзор
Документация
Войти
/
h0tnanny
/
DeliveryService
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
DeliveryService.API/Controllers/FeedbackController.cs
77 строк
3 KB
Хатнянский Максим
Поправлены все связи EF Core
16 мар 2024, 12:47
16 мар 2024, 12:47
3434e4b
Код
Авторство
О чём код?
// using DeliveryService.API.Models; // using DeliveryService.Persistence; // using DeliveryService.Persistence.Models; // using Microsoft.AspNetCore.Mvc; // using Microsoft.EntityFrameworkCore; // // namespace DeliveryService.API.Controllers; // // [ApiController] // [Route("[controller]")] // public sealed class FeedbackController(ILogger<FeedbackController> logger, DeliveryDbContext context) : ControllerBase // { // [HttpGet("{id}")] // [ProducesResponseType<Feedback>(StatusCodes.Status200OK)] // public async Task<IActionResult> Get(Guid id) // { // var feedback = await context.Feedbacks.FirstOrDefaultAsync(x => x.Id == id); // if (feedback == null) return NotFound(); // // return Ok(feedback); // } // // [HttpGet("GetAll")] // [ProducesResponseType<IEnumerable<Feedback>>(StatusCodes.Status200OK)] // public async Task<IActionResult> GetAll() // { // var feedbacks = await context.Feedbacks.ToListAsync(); // return Ok(feedbacks); // } // // [HttpPost("Create")] // [ProducesResponseType<Feedback>(StatusCodes.Status200OK)] // public async Task<IActionResult> Create(Guid id, [FromBody] FeedbackModel feedback) // { // var product = await context.Products.FirstOrDefaultAsync(x => x.Id == id); // if (product == null) return BadRequest("Такого продукта не существует"); // // var newFeedback = new Feedback() // { // Id = Guid.NewGuid(), // ProductId = id, // Product = product, // FeedbackText = feedback.FeedbackText, // Rating = feedback.Rating // }; // // context.Feedbacks.Add(newFeedback); // await context.SaveChangesAsync(); // // return Ok(newFeedback); // } // // [HttpPut("Update{id:guid}")] // [ProducesResponseType<Feedback>(StatusCodes.Status200OK)] // public async Task<IActionResult> Update(Guid id, [FromBody] FeedbackModel feedback) // { // var feedbackToUpdate = await context.Feedbacks.FirstOrDefaultAsync(x => x.Id == id); // if (feedbackToUpdate == null) return NotFound(); // // feedbackToUpdate.FeedbackText = feedback.FeedbackText; // feedbackToUpdate.Rating = feedback.Rating; // // await context.SaveChangesAsync(); // return Ok(feedbackToUpdate); // } // // [HttpDelete("Delete{id:guid}")] // public async Task<IActionResult> Delete(Guid id) // { // var feedback = await context.Feedbacks.FirstOrDefaultAsync(x => x.Id == id); // if (feedback == null) return NoContent(); // // context.Feedbacks.Remove(feedback); // await context.SaveChangesAsync(); // return Ok(feedback); // } // }