Skip to content

Commit

Permalink
[Quotations management][Duy] Refactor QuotationService after updating…
Browse files Browse the repository at this point in the history
… database
  • Loading branch information
duykasama committed Mar 3, 2024
1 parent 4fd183d commit 467f7ad
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 136 deletions.
5 changes: 5 additions & 0 deletions Domus.DAL/Domus.DAL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.14" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Interfaces\IProductDetailQuotationRepository.cs" />
<Compile Remove="Implementations\ProductDetailQuotationRepository.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Domus.DAL.Interfaces;
using Domus.Domain.Entities;

namespace Domus.DAL.Implementations;

public class ProductDetailQuoationRevisionRepository : GenericRepository<ProductDetailQuotationRevision>, IProductDetailQuotationRevisionRepository
{
public ProductDetailQuoationRevisionRepository(IAppDbContext dbContext) : base(dbContext)
{
}
}
11 changes: 11 additions & 0 deletions Domus.DAL/Implementations/QuotationRevisionRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Domus.DAL.Interfaces;
using Domus.Domain.Entities;

namespace Domus.DAL.Implementations;

public class QuotationRevisionRepository : GenericRepository<QuotationRevision>, IQuotationRevisionRepository
{
public QuotationRevisionRepository(IAppDbContext dbContext) : base(dbContext)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Domus.Common.Interfaces;
using Domus.Domain.Entities;

namespace Domus.DAL.Interfaces;

public interface IProductDetailQuotationRevisionRepository : IGenericRepository<ProductDetailQuotationRevision>, IAutoRegisterable
{
}
8 changes: 8 additions & 0 deletions Domus.DAL/Interfaces/IQuotationRevisionRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Domus.Common.Interfaces;
using Domus.Domain.Entities;

namespace Domus.DAL.Interfaces;

public interface IQuotationRevisionRepository : IGenericRepository<QuotationRevision>, IAutoRegisterable
{
}
18 changes: 18 additions & 0 deletions Domus.Domain/Dtos/Quotations/DtoProductDetailQuotationRevision.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Domus.Domain.Dtos.Products;

namespace Domus.Domain.Dtos.Quotations;

public class DtoProductDetailQuotationRevision
{
public string ProductName { get; set; } = null!;

public double Price { get; set; }

public string MonetaryUnit { get; set; } = null!;

public double Quantity { get; set; }

public string QuantityType { get; set; } = null!;

public DtoProductDetail Detail { get; set; } = null!;
}
4 changes: 2 additions & 2 deletions Domus.Domain/Dtos/Quotations/DtoQuotationFullDetails.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using Domus.Domain.Dtos.Products;

namespace Domus.Domain.Dtos.Quotations;

Expand All @@ -18,7 +17,8 @@ public class DtoQuotationFullDetails
public DateTime? ExpireAt { get; set; }

[JsonPropertyName("products")]
public ICollection<DtoProductDetailQuotation> ProductDetailQuotations { get; set; } = new List<DtoProductDetailQuotation>();
// public ICollection<DtoProductDetailQuotation> ProductDetailQuotations { get; set; } = new List<DtoProductDetailQuotation>();
public ICollection<DtoProductDetailQuotationRevision> ProductDetailQuotations { get; set; } = new List<DtoProductDetailQuotationRevision>();

[JsonPropertyName("services")]
public ICollection<DtoServiceQuotation> ServiceQuotations { get; set; } = new List<DtoServiceQuotation>();
Expand Down
14 changes: 7 additions & 7 deletions Domus.Service/AutoMappings/AutoMapperConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private static void CreateProductMaps(IMapperConfigurationExpression mapper)
mapper.CreateMap<ProductDetail, DtoProductDetailPackage>()
.ForMember(dest => dest.ProductName, opt => opt.MapFrom(src => src.Product.ProductName));

mapper.CreateMap<ProductDetailQuotation, DtoProductDetailQuotation>()
mapper.CreateMap<ProductDetailQuotationRevision, DtoProductDetailQuotationRevision>()
.ForMember(dest => dest.ProductName,
opt => opt.MapFrom(src => src.ProductDetail.Product.ProductName));

Expand Down Expand Up @@ -196,16 +196,16 @@ private static void CreateQuotationMaps(IMapperConfigurationExpression mapper)
opt => opt.Condition(src => !string.IsNullOrEmpty(src.Status)))
.ForMember(dest => dest.ExpireAt,
opt => opt.Condition(src => src.ExpireAt != default))
.ForMember(dest => dest.ProductDetailQuotations,
.ForMember(dest => dest.QuotationRevisions,
opt => opt.Ignore())
.ForMember(dest => dest.ServiceQuotations,
opt => opt.Ignore());

mapper.CreateMap<ProductDetailInUpdatingQuotationRequest, ProductDetailQuotation>()
.ForMember(dest => dest.MonetaryUnit,
opt => opt.Condition(src => !string.IsNullOrEmpty(src.MonetaryUnit)))
.ForMember(dest => dest.QuantityType,
opt => opt.Condition(src => !string.IsNullOrEmpty(src.QuantityType)));
// mapper.CreateMap<ProductDetailInUpdatingQuotationRequest, ProductDetailQuotation>()
// .ForMember(dest => dest.MonetaryUnit,
// opt => opt.Condition(src => !string.IsNullOrEmpty(src.MonetaryUnit)))
// .ForMember(dest => dest.QuantityType,
// opt => opt.Condition(src => !string.IsNullOrEmpty(src.QuantityType)));

mapper.CreateMap<NegotiationMessage, DtoNegotiationMessage>();
}
Expand Down
Loading

0 comments on commit 467f7ad

Please sign in to comment.