File tree 8 files changed +24
-17
lines changed
8 files changed +24
-17
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ public record ProductForUpdateDto(
4
4
int Id ,
5
5
string Name ,
6
6
string Description ,
7
- decimal Price ,
7
+ decimal SalePrice ,
8
+ decimal SupplyPrice ,
8
9
DateTime ExpireDate ,
9
10
int CategoryId ) ;
10
11
}
Original file line number Diff line number Diff line change 1
- namespace Inflow . Domain . DTOs . SaleItem
1
+ using Inflow . Domain . DTOs . Product ;
2
+
3
+ namespace Inflow . Domain . DTOs . SaleItem
2
4
{
3
5
public record SaleItemDto (
4
- int Id ,
5
- int Quantity ,
6
- decimal UnitPrice ,
7
- int ProductId ,
8
- int SaleId ) ;
6
+ int Id ,
7
+ string ProductName ,
8
+ int Quantity ,
9
+ decimal UnitPrice ,
10
+ ProductDto Product ,
11
+ int SaleId ,
12
+ decimal TotalDue ) ;
9
13
}
Original file line number Diff line number Diff line change 3
3
public class Category : EntityBase
4
4
{
5
5
public string ? Name { get ; set ; }
6
- public virtual ICollection < Product > ? Products { get ; set ; }
6
+ public virtual ICollection < Product > Products { get ; set ; }
7
7
}
8
8
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class SaleItem : EntityBase
6
6
public decimal UnitPrice { get ; set ; }
7
7
8
8
public int ProductId { get ; set ; }
9
- public Product ? Product { get ; set ; }
9
+ public Product Product { get ; set ; }
10
10
11
11
public int SaleId { get ; set ; }
12
12
public Sale ? Sale { get ; set ; }
Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ namespace Inflow.Domain.Mappings
6
6
{
7
7
public class CategoryMappings : Profile
8
8
{
9
- public CategoryMappings ( )
9
+ public CategoryMappings ( )
10
10
{
11
11
CreateMap < Category , CategoryDto > ( )
12
- . ForMember ( x => x . NumberOfProducts , r => r . MapFrom ( x => x . Products . Count ) ) ;
12
+ . ForMember ( x => x . NumberOfProducts , r => r . MapFrom ( x => x . Products . Count ( ) ) ) ;
13
13
CreateMap < CategoryDto , Category > ( ) ;
14
14
CreateMap < CategoryForCreateDto , Category > ( ) ;
15
15
CreateMap < Category , CategoryForCreateDto > ( ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace Inflow.Domain.Mappings
6
6
{
7
7
public class ProductMappings : Profile
8
8
{
9
- public ProductMappings ( )
9
+ public ProductMappings ( )
10
10
{
11
11
CreateMap < Product , ProductDto > ( )
12
12
. ForMember ( x => x . SupplyPrice , r => r . MapFrom ( x => x . Price ) )
@@ -15,7 +15,8 @@ public ProductMappings()
15
15
CreateMap < ProductDto , Product > ( ) ;
16
16
CreateMap < ProductForCreateDto , Product > ( )
17
17
. ForMember ( x => x . Price , r => r . MapFrom ( x => x . SupplyPrice ) ) ;
18
- CreateMap < ProductForUpdateDto , Product > ( ) ;
18
+ CreateMap < ProductForUpdateDto , Product > ( )
19
+ . ForMember ( x => x . Price , r => r . MapFrom ( x => x . SupplyPrice ) ) ;
19
20
CreateMap < Product , ProductForCreateDto > ( ) ;
20
21
CreateMap < Product , ProductForUpdateDto > ( ) ;
21
22
}
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ namespace Inflow.Domain.Mappings
7
7
{
8
8
public class SaleItemMappings : Profile
9
9
{
10
- public SaleItemMappings ( )
10
+ public SaleItemMappings ( )
11
11
{
12
12
CreateMap < SaleItemDto , SaleItem > ( ) ;
13
- CreateMap < SaleItem , SaleItemDto > ( ) ;
13
+ CreateMap < SaleItem , SaleItemDto > ( )
14
+ . ForCtorParam ( nameof ( SaleItemDto . TotalDue ) , x => x . MapFrom ( q => q . Quantity * q . UnitPrice ) )
15
+ . ForCtorParam ( nameof ( SaleItemDto . ProductName ) , x => x . MapFrom ( q => q . Product . Name ) ) ;
14
16
CreateMap < SaleItemForCreateDto , SaleItem > ( ) ;
15
17
CreateMap < SaleItemForUpdateDto , SaleItem > ( ) ;
16
18
}
Original file line number Diff line number Diff line change 1
1
using AutoMapper ;
2
- using Inflow . Domain . DTOs . Sale ;
3
2
using Inflow . Domain . DTOs . Supply ;
4
3
using Inflow . Domain . Entities ;
5
4
6
5
namespace Inflow . Domain . Mappings
7
6
{
8
7
public class SupplyMappings : Profile
9
8
{
10
- public SupplyMappings ( )
9
+ public SupplyMappings ( )
11
10
{
12
11
CreateMap < SupplyDto , Supply > ( )
13
12
. PreserveReferences ( ) ;
You can’t perform that action at this time.
0 commit comments