This commit is contained in:
Tizian.Breuch
2025-09-08 11:24:10 +02:00
parent 471f4a2e7a
commit 5b84ccc575
15 changed files with 352 additions and 63 deletions

View File

@@ -1,18 +1,36 @@
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
// src/Webshop.Api/Controllers/Customer/ReviewsController.cs
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Reviews;
using Webshop.Application.Services.Customers;
namespace Webshop.Api.Controllers.Customers
namespace Webshop.Api.Controllers.Customer
{
[ApiController]
[Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")]
public class ReviewsController : ControllerBase
{
private readonly ICustomerReviewService _customerReviewService;
public ReviewsController(ICustomerReviewService customerReviewService)
{
_customerReviewService = customerReviewService;
}
[HttpPost]
public async Task<IActionResult> CreateReview([FromBody] CreateReviewDto reviewDto)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var result = await _customerReviewService.CreateReviewAsync(reviewDto, userId);
if (result.Type == Application.ServiceResultType.Success)
{
return Ok(result.Value);
}
return BadRequest(new { Message = result.ErrorMessage });
}
}
}
}