review
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// src/Webshop.Api/Controllers/Public/ReviewsController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Products; // Für ProductDto
|
||||
using Webshop.Application;
|
||||
using Webshop.Application.DTOs.Reviews;
|
||||
using Webshop.Application.Services.Public;
|
||||
|
||||
@@ -23,10 +24,18 @@ namespace Webshop.Api.Controllers.Public
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ReviewDto>>> GetApprovedReviews(Guid productId)
|
||||
[ProducesResponseType(typeof(IEnumerable<ReviewDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetApprovedReviews(Guid productId)
|
||||
{
|
||||
var reviews = await _reviewService.GetApprovedReviewsByProductIdAsync(productId);
|
||||
return Ok(reviews);
|
||||
var result = await _reviewService.GetApprovedReviewsByProductIdAsync(productId);
|
||||
|
||||
return result.Type switch
|
||||
{
|
||||
ServiceResultType.Success => Ok(result.Value),
|
||||
ServiceResultType.NotFound => NotFound(new { Message = result.ErrorMessage }),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, "Ein unerwarteter Fehler ist aufgetreten.")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user