Make amount, user_id and address_id optional in user order update

This commit is contained in:
masoodafar-web
2025-11-28 04:02:00 +03:30
parent 84f08f11e4
commit ce2bf3f1f0
5 changed files with 22 additions and 21 deletions

View File

@@ -6,19 +6,19 @@ public record UpdateUserOrderCommand : IRequest<Unit>
//شناسه //شناسه
public long Id { get; init; } public long Id { get; init; }
//قیمت //قیمت
public long Amount { get; init; } public long? Amount { get; init; }
//شناسه پکیج //شناسه پکیج
public long? PackageId { get; init; } public long? PackageId { get; init; }
//شناسه تراکنش //شناسه تراکنش
public long? TransactionId { get; init; } public long? TransactionId { get; init; }
//وضعیت پرداخت //وضعیت پرداخت
public PaymentStatus PaymentStatus { get; init; } public PaymentStatus? PaymentStatus { get; init; }
//تاریخ پرداخت //تاریخ پرداخت
public DateTime? PaymentDate { get; init; } public DateTime? PaymentDate { get; init; }
//شناسه کاربر //شناسه کاربر
public long UserId { get; init; } public long? UserId { get; init; }
//شناسه آدرس کاربر //شناسه آدرس کاربر
public long UserAddressId { get; init; } public long? UserAddressId { get; init; }
// //
public PaymentMethod? PaymentMethod { get; init; } public PaymentMethod? PaymentMethod { get; init; }
// وضعیت ارسال سفارش // وضعیت ارسال سفارش

View File

@@ -5,19 +5,19 @@ public class UpdateUserOrderCommandValidator : AbstractValidator<UpdateUserOrder
{ {
RuleFor(model => model.Id) RuleFor(model => model.Id)
.NotNull(); .NotNull();
RuleFor(model => model.Amount) // RuleFor(model => model.Amount)
.NotNull(); // .NotNull();
RuleFor(model => model.PackageId) // RuleFor(model => model.PackageId)
.NotNull(); // .NotNull();
RuleFor(model => model.PaymentStatus) // RuleFor(model => model.PaymentStatus)
.IsInEnum() // .IsInEnum()
.NotNull(); // .NotNull();
RuleFor(model => model.UserId) // RuleFor(model => model.UserId)
.NotNull(); // .NotNull();
RuleFor(model => model.UserAddressId) // RuleFor(model => model.UserAddressId)
.NotNull(); // .NotNull();
RuleFor(model => model.PaymentMethod) // RuleFor(model => model.PaymentMethod)
.IsInEnum(); // .IsInEnum();
} }
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) => public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{ {

View File

@@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.135</Version> <Version>0.0.137</Version>
<DebugType>None</DebugType> <DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols> <DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> <GeneratePackageOnBuild>False</GeneratePackageOnBuild>

View File

@@ -74,7 +74,7 @@ message CreateNewUserOrderResponse
message UpdateUserOrderRequest message UpdateUserOrderRequest
{ {
int64 id = 1; int64 id = 1;
int64 amount = 2; google.protobuf.Int64Value amount = 2;
google.protobuf.Int64Value package_id = 3; google.protobuf.Int64Value package_id = 3;
google.protobuf.Int64Value transaction_id = 4; google.protobuf.Int64Value transaction_id = 4;
oneof PaymentStatus_item oneof PaymentStatus_item
@@ -82,8 +82,8 @@ message UpdateUserOrderRequest
messages.PaymentStatus payment_status = 5; messages.PaymentStatus payment_status = 5;
} }
google.protobuf.Timestamp payment_date = 6; google.protobuf.Timestamp payment_date = 6;
int64 user_id = 7; google.protobuf.Int64Value user_id = 7;
int64 user_address_id = 8; google.protobuf.Int64Value user_address_id = 8;
oneof PaymentMethod_item oneof PaymentMethod_item
{ {
messages.PaymentMethod payment_method = 9; messages.PaymentMethod payment_method = 9;

View File

@@ -5,6 +5,7 @@ public class GeneralMapping : IRegister
{ {
void IRegister.Register(TypeAdapterConfig config) void IRegister.Register(TypeAdapterConfig config)
{ {
config.Default.IgnoreNullValues(true);
config.NewConfig<string, decimal>() config.NewConfig<string, decimal>()
.MapWith(src => decimal.Parse(src)); .MapWith(src => decimal.Parse(src));