-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
namespace DistributionCenter.Application.Tables.Components.Information.Concretes; | ||
|
||
using Bases; | ||
|
||
public class OrderProductTableInformation : BaseEntityTableInformation | ||
{ | ||
public OrderProductTableInformation() | ||
: base() { } | ||
|
||
protected override string ObtainGetByIdFields() | ||
{ | ||
return "quantity AS Quantity, product_id AS ProductId, client_order_id AS OrderId"; | ||
} | ||
|
||
protected override string ObtainTableName() | ||
{ | ||
return "client_order_product"; | ||
} | ||
|
||
protected override string ObtainCreateFields() | ||
{ | ||
return "quantity, product_id, client_order_id"; | ||
} | ||
|
||
protected override string ObtainCreateValues() | ||
{ | ||
return "@Quantity, @ProductId, @OrderId"; | ||
} | ||
|
||
protected override string ObtainUpdateFields() | ||
{ | ||
return "quantity = @Quantity, product_id = @ProductId, client_order_id = @OrderId"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace DistributionCenter.Application.Tables.Core.Concretes; | ||
|
||
using System.Data; | ||
using Bases; | ||
using Components.Information.Concretes; | ||
using Components.Information.Interfaces; | ||
using Connections.Dapper.Interfaces; | ||
using Domain.Entities.Concretes; | ||
|
||
public class OrderProductTable(IDbConnectionFactory<IDbConnection> dbConnectionFactory) : BaseDapperTable<OrderProduct>(dbConnectionFactory) | ||
{ | ||
public override ITableInformation GetInformation() | ||
{ | ||
return new OrderProductTableInformation(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace DistributionCenter.Infraestructure.DTOs.Concretes.Orders; | ||
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/CreateOrderProductDto.cs GitHub Actions / build
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/CreateOrderProductDto.cs GitHub Actions / build
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/CreateOrderProductDto.cs GitHub Actions / Build Project (ubuntu-latest, 8.0.x)
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/CreateOrderProductDto.cs GitHub Actions / Build Project (ubuntu-latest, 8.0.x)
|
||
|
||
using Commons.Results; | ||
using Domain.Entities.Concretes; | ||
using Interfaces; | ||
|
||
public class CreateOrderProductDto : ICreateDto<OrderProduct> | ||
{ | ||
public required Guid ProductId { get; set; } | ||
public required int Quantity { get; set; } | ||
|
||
public OrderProduct ToEntity() | ||
{ | ||
return new OrderProduct | ||
{ | ||
ProductId = ProductId, | ||
Quantity = Quantity | ||
}; | ||
} | ||
|
||
public Result Validate() | ||
{ | ||
return Result.Ok(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace DistributionCenter.Infraestructure.DTOs.Concretes.Orders; | ||
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/UpdateOrderProductDto.cs GitHub Actions / build
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/UpdateOrderProductDto.cs GitHub Actions / build
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/UpdateOrderProductDto.cs GitHub Actions / Build Project (ubuntu-latest, 8.0.x)
Check failure on line 1 in src/DistributionCenter.Infraestructure/DTOs/Concretes/OrderProducts/UpdateOrderProductDto.cs GitHub Actions / Build Project (ubuntu-latest, 8.0.x)
|
||
|
||
using Commons.Results; | ||
using Domain.Entities.Concretes; | ||
using Interfaces; | ||
|
||
public class UpdateOrderProductDto : IUpdateDto<OrderProduct> | ||
{ | ||
public Guid ProductId { get; set; } | ||
public int? Quantity { get; set; } | ||
|
||
public OrderProduct FromEntity(OrderProduct entity) | ||
{ | ||
entity.ProductId = ProductId; | ||
entity.Quantity = Quantity ?? entity.Quantity; | ||
|
||
return entity; | ||
} | ||
|
||
public Result Validate() | ||
{ | ||
return Result.Ok(); | ||
} | ||
} |