added UpdateQuotationDto.cs

This commit is contained in:
2025-12-12 21:18:13 +01:00
parent 65cff130e4
commit 2fa74ccba8
3 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.Quotation.Request;
public class UpdateQuotationDto
{
public int Id { get; set; }
public string? Message { get; set; }
public string? ConditionsSale { get; set; }
}

View File

@@ -1,8 +1,6 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;
namespace PyroFetes.Endpoints.Quotations;
public class UpdateQuotationEndpoint(
QuotationsRepository quotationsRepository,
AutoMapper.IMapper mapper) : Endpoint<UpdateQuotationDto, GetQuotationDto>
{
public override void Configure()
{
Put("/quotations/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(UpdateQuotationDto req, CancellationToken ct)
{
Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct);
if (quotation == null)
{
await Send.NotFoundAsync(ct);
return;
}
quotation.ConditionsSale = req.ConditionsSale;
quotation.Message = req.Message;
await quotationsRepository.UpdateAsync(quotation, ct);
await Send.OkAsync(mapper.Map<GetQuotationDto>(quotation), ct);
}
}