Generator Changes at 10/13/2025 8:08:52 AM
This commit is contained in:
@@ -4,10 +4,10 @@ public interface IApplicationDbContext
|
|||||||
{
|
{
|
||||||
DbSet<UserAddress> UserAddresss { get; }
|
DbSet<UserAddress> UserAddresss { get; }
|
||||||
DbSet<Package> Packages { get; }
|
DbSet<Package> Packages { get; }
|
||||||
DbSet<UserOrder> UserOrders { get; }
|
|
||||||
DbSet<Role> Roles { get; }
|
DbSet<Role> Roles { get; }
|
||||||
DbSet<UserRole> UserRoles { get; }
|
DbSet<UserRole> UserRoles { get; }
|
||||||
DbSet<OtpToken> OtpTokens { get; }
|
DbSet<OtpToken> OtpTokens { get; }
|
||||||
|
DbSet<UserOrder> UserOrders { get; }
|
||||||
DbSet<User> Users { get; }
|
DbSet<User> Users { get; }
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserAddressCQ.Commands.SetAddressAsDefault;
|
||||||
|
public record SetAddressAsDefaultCommand : IRequest<Unit>
|
||||||
|
{
|
||||||
|
//شناسه
|
||||||
|
public long Id { get; init; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using CMSMicroservice.Domain.Events;
|
||||||
|
namespace CMSMicroservice.Application.UserAddressCQ.Commands.SetAddressAsDefault;
|
||||||
|
public class SetAddressAsDefaultCommandHandler : IRequestHandler<SetAddressAsDefaultCommand, Unit>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public SetAddressAsDefaultCommandHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Unit> Handle(SetAddressAsDefaultCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var entity = await _context.UserAddresss
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserAddress), request.Id);
|
||||||
|
|
||||||
|
var entities = await _context.UserAddresss
|
||||||
|
.Where(x => x.UserId == entity.UserId)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
entities.ForEach(x => x.IsDefault = false);
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
entity.IsDefault = true;
|
||||||
|
_context.UserAddresss.Update(entity);
|
||||||
|
entity.AddDomainEvent(new SetAddressAsDefaultEvent(entity));
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
return Unit.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserAddressCQ.Commands.SetAddressAsDefault;
|
||||||
|
public class SetAddressAsDefaultCommandValidator : AbstractValidator<SetAddressAsDefaultCommand>
|
||||||
|
{
|
||||||
|
public SetAddressAsDefaultCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(model => model.Id)
|
||||||
|
.NotNull();
|
||||||
|
}
|
||||||
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
|
{
|
||||||
|
var result = await ValidateAsync(ValidationContext<SetAddressAsDefaultCommand>.CreateWithOptions((SetAddressAsDefaultCommand)model, x => x.IncludeProperties(propertyName)));
|
||||||
|
if (result.IsValid)
|
||||||
|
return Array.Empty<string>();
|
||||||
|
return result.Errors.Select(e => e.ErrorMessage);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using CMSMicroservice.Domain.Events;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.UserAddressCQ.EventHandlers;
|
||||||
|
|
||||||
|
public class SetAddressAsDefaultEventHandler : INotificationHandler<SetAddressAsDefaultEvent>
|
||||||
|
{
|
||||||
|
private readonly ILogger<SetAddressAsDefaultEventHandler> _logger;
|
||||||
|
|
||||||
|
public SetAddressAsDefaultEventHandler(ILogger<SetAddressAsDefaultEventHandler> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(SetAddressAsDefaultEvent notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,5 +13,13 @@ public record CreateNewUserCommand : IRequest<CreateNewUserResponseDto>
|
|||||||
public string? AvatarPath { get; init; }
|
public string? AvatarPath { get; init; }
|
||||||
//شناسه والد
|
//شناسه والد
|
||||||
public long? ParentId { get; init; }
|
public long? ParentId { get; init; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool EmailNotifications { get; init; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool SmsNotifications { get; init; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool PushNotifications { get; init; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,12 @@ public class CreateNewUserCommandValidator : AbstractValidator<CreateNewUserComm
|
|||||||
{
|
{
|
||||||
RuleFor(model => model.Mobile)
|
RuleFor(model => model.Mobile)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
RuleFor(model => model.EmailNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.SmsNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.PushNotifications)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,5 +15,13 @@ public record UpdateUserCommand : IRequest<Unit>
|
|||||||
public bool IsRulesAccepted { get; init; }
|
public bool IsRulesAccepted { get; init; }
|
||||||
//تاریخ پذیرش قوانین
|
//تاریخ پذیرش قوانین
|
||||||
public DateTime? RulesAcceptedAt { get; init; }
|
public DateTime? RulesAcceptedAt { get; init; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool EmailNotifications { get; init; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool SmsNotifications { get; init; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool PushNotifications { get; init; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,12 @@ public class UpdateUserCommandValidator : AbstractValidator<UpdateUserCommand>
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.IsRulesAccepted)
|
RuleFor(model => model.IsRulesAccepted)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.EmailNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.SmsNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.PushNotifications)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,4 +30,12 @@ public record GetAllUserByFilterQuery : IRequest<GetAllUserByFilterResponseDto>
|
|||||||
public bool? IsMobileVerified { get; set; }
|
public bool? IsMobileVerified { get; set; }
|
||||||
//تاریخ فعال سازی موبایل
|
//تاریخ فعال سازی موبایل
|
||||||
public DateTime? MobileVerifiedAt { get; set; }
|
public DateTime? MobileVerifiedAt { get; set; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool? EmailNotifications { get; set; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool? SmsNotifications { get; set; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool? PushNotifications { get; set; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ public class GetAllUserByFilterQueryHandler : IRequestHandler<GetAllUserByFilter
|
|||||||
.Where(x => request.Filter.ReferralCode == null || x.ReferralCode == request.Filter.ReferralCode)
|
.Where(x => request.Filter.ReferralCode == null || x.ReferralCode == request.Filter.ReferralCode)
|
||||||
.Where(x => request.Filter.IsMobileVerified == null || x.IsMobileVerified == request.Filter.IsMobileVerified)
|
.Where(x => request.Filter.IsMobileVerified == null || x.IsMobileVerified == request.Filter.IsMobileVerified)
|
||||||
.Where(x => request.Filter.ParentId == null || x.ParentId == request.Filter.ParentId)
|
.Where(x => request.Filter.ParentId == null || x.ParentId == request.Filter.ParentId)
|
||||||
|
.Where(x => request.Filter.SmsNotifications == null || x.SmsNotifications == request.Filter.SmsNotifications)
|
||||||
|
.Where(x => request.Filter.EmailNotifications == null || x.EmailNotifications == request.Filter.EmailNotifications)
|
||||||
|
.Where(x => request.Filter.PushNotifications == null || x.PushNotifications == request.Filter.PushNotifications)
|
||||||
|
.Where(x => request.Filter.BirthDate == null || x.BirthDate == request.Filter.BirthDate)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
return new GetAllUserByFilterResponseDto
|
return new GetAllUserByFilterResponseDto
|
||||||
|
|||||||
@@ -28,4 +28,12 @@ public class GetAllUserByFilterResponseDto
|
|||||||
public bool IsMobileVerified { get; set; }
|
public bool IsMobileVerified { get; set; }
|
||||||
//تاریخ فعال سازی موبایل
|
//تاریخ فعال سازی موبایل
|
||||||
public DateTime? MobileVerifiedAt { get; set; }
|
public DateTime? MobileVerifiedAt { get; set; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool EmailNotifications { get; set; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool SmsNotifications { get; set; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool PushNotifications { get; set; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,13 @@ public class GetUserResponseDto
|
|||||||
public bool IsMobileVerified { get; set; }
|
public bool IsMobileVerified { get; set; }
|
||||||
//تاریخ فعال سازی موبایل
|
//تاریخ فعال سازی موبایل
|
||||||
public DateTime? MobileVerifiedAt { get; set; }
|
public DateTime? MobileVerifiedAt { get; set; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool EmailNotifications { get; set; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool SmsNotifications { get; set; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool PushNotifications { get; set; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,7 @@ public record CreateNewUserOrderCommand : IRequest<CreateNewUserOrderResponseDto
|
|||||||
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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ public class CreateNewUserOrderCommandValidator : AbstractValidator<CreateNewUse
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserAddressId)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,5 +15,7 @@ public record UpdateUserOrderCommand : IRequest<Unit>
|
|||||||
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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ public class UpdateUserOrderCommandValidator : AbstractValidator<UpdateUserOrder
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserAddressId)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,4 +24,6 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
|
|||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long? UserId { get; set; }
|
public long? UserId { get; set; }
|
||||||
|
//شناسه آدرس کاربر
|
||||||
|
public long? UserAddressId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class GetAllUserOrderByFilterQueryHandler : IRequestHandler<GetAllUserOrd
|
|||||||
.Where(x => request.Filter.PaymentStatus == null || x.PaymentStatus == request.Filter.PaymentStatus)
|
.Where(x => request.Filter.PaymentStatus == null || x.PaymentStatus == request.Filter.PaymentStatus)
|
||||||
.Where(x => request.Filter.PaymentDate == null || x.PaymentDate == request.Filter.PaymentDate)
|
.Where(x => request.Filter.PaymentDate == null || x.PaymentDate == request.Filter.PaymentDate)
|
||||||
.Where(x => request.Filter.UserId == null || x.UserId == request.Filter.UserId)
|
.Where(x => request.Filter.UserId == null || x.UserId == request.Filter.UserId)
|
||||||
|
.Where(x => request.Filter.UserAddressId == null || x.UserAddressId == request.Filter.UserAddressId)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
return new GetAllUserOrderByFilterResponseDto
|
return new GetAllUserOrderByFilterResponseDto
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ public class GetAllUserOrderByFilterResponseDto
|
|||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
|
//شناسه آدرس کاربر
|
||||||
|
public long UserAddressId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,7 @@ public class GetUserOrderResponseDto
|
|||||||
public DateTime? PaymentDate { get; set; }
|
public DateTime? PaymentDate { get; set; }
|
||||||
//شناسه کاربر
|
//شناسه کاربر
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
|
//شناسه آدرس کاربر
|
||||||
|
public long UserAddressId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,12 +26,20 @@ public class User : BaseAuditableEntity
|
|||||||
public bool IsRulesAccepted { get; set; }
|
public bool IsRulesAccepted { get; set; }
|
||||||
//تاریخ پذیرش قوانین
|
//تاریخ پذیرش قوانین
|
||||||
public DateTime? RulesAcceptedAt { get; set; }
|
public DateTime? RulesAcceptedAt { get; set; }
|
||||||
|
//اعلان ایمیل
|
||||||
|
public bool EmailNotifications { get; set; }
|
||||||
|
//اعلان پیامک
|
||||||
|
public bool SmsNotifications { get; set; }
|
||||||
|
//اعلان پوش
|
||||||
|
public bool PushNotifications { get; set; }
|
||||||
|
//تاریخ تولد
|
||||||
|
public DateTime? BirthDate { get; set; }
|
||||||
//UserAddress Collection Navigation Reference
|
//UserAddress Collection Navigation Reference
|
||||||
public virtual ICollection<UserAddress> UserAddresss { get; set; }
|
public virtual ICollection<UserAddress> UserAddresss { get; set; }
|
||||||
//UserOrder Collection Navigation Reference
|
|
||||||
public virtual ICollection<UserOrder> UserOrders { get; set; }
|
|
||||||
//UserRole Collection Navigation Reference
|
//UserRole Collection Navigation Reference
|
||||||
public virtual ICollection<UserRole> UserRoles { get; set; }
|
public virtual ICollection<UserRole> UserRoles { get; set; }
|
||||||
|
//UserOrder Collection Navigation Reference
|
||||||
|
public virtual ICollection<UserOrder> UserOrders { get; set; }
|
||||||
//User Collection Navigation Reference
|
//User Collection Navigation Reference
|
||||||
public virtual ICollection<User> Users { get; set; }
|
public virtual ICollection<User> Users { get; set; }
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,6 @@ public class UserAddress : BaseAuditableEntity
|
|||||||
public bool IsDefault { get; set; }
|
public bool IsDefault { get; set; }
|
||||||
//شناسه شهر
|
//شناسه شهر
|
||||||
public long CityId { get; set; }
|
public long CityId { get; set; }
|
||||||
|
//UserOrder Collection Navigation Reference
|
||||||
|
public virtual ICollection<UserOrder> UserOrders { get; set; }
|
||||||
}
|
}
|
||||||
@@ -18,4 +18,8 @@ public class UserOrder : BaseAuditableEntity
|
|||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
//User Navigation Property
|
//User Navigation Property
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
//شناسه آدرس کاربر
|
||||||
|
public long UserAddressId { get; set; }
|
||||||
|
//UserAddress Navigation Property
|
||||||
|
public virtual UserAddress UserAddress { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace CMSMicroservice.Domain.Events;
|
||||||
|
public class SetAddressAsDefaultEvent : BaseEvent
|
||||||
|
{
|
||||||
|
public SetAddressAsDefaultEvent(UserAddress item)
|
||||||
|
{
|
||||||
|
Item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAddress Item { get; }
|
||||||
|
}
|
||||||
@@ -41,10 +41,10 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
|||||||
}
|
}
|
||||||
public DbSet<UserAddress> UserAddresss => Set<UserAddress>();
|
public DbSet<UserAddress> UserAddresss => Set<UserAddress>();
|
||||||
public DbSet<Package> Packages => Set<Package>();
|
public DbSet<Package> Packages => Set<Package>();
|
||||||
public DbSet<UserOrder> UserOrders => Set<UserOrder>();
|
|
||||||
public DbSet<Role> Roles => Set<Role>();
|
public DbSet<Role> Roles => Set<Role>();
|
||||||
public DbSet<UserRole> UserRoles => Set<UserRole>();
|
public DbSet<UserRole> UserRoles => Set<UserRole>();
|
||||||
public DbSet<OtpToken> OtpTokens => Set<OtpToken>();
|
public DbSet<OtpToken> OtpTokens => Set<OtpToken>();
|
||||||
|
public DbSet<UserOrder> UserOrders => Set<UserOrder>();
|
||||||
public DbSet<User> Users => Set<User>();
|
public DbSet<User> Users => Set<User>();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,5 +27,9 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
|
|||||||
builder.Property(entity => entity.MobileVerifiedAt).IsRequired(false);
|
builder.Property(entity => entity.MobileVerifiedAt).IsRequired(false);
|
||||||
builder.Property(entity => entity.IsRulesAccepted).IsRequired(true);
|
builder.Property(entity => entity.IsRulesAccepted).IsRequired(true);
|
||||||
builder.Property(entity => entity.RulesAcceptedAt).IsRequired(false);
|
builder.Property(entity => entity.RulesAcceptedAt).IsRequired(false);
|
||||||
|
builder.Property(entity => entity.EmailNotifications).IsRequired(true);
|
||||||
|
builder.Property(entity => entity.SmsNotifications).IsRequired(true);
|
||||||
|
builder.Property(entity => entity.PushNotifications).IsRequired(true);
|
||||||
|
builder.Property(entity => entity.BirthDate).IsRequired(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,5 +26,11 @@ public class UserOrderConfiguration : IEntityTypeConfiguration<UserOrder>
|
|||||||
.WithMany(entity => entity.UserOrders)
|
.WithMany(entity => entity.UserOrders)
|
||||||
.HasForeignKey(entity => entity.UserId)
|
.HasForeignKey(entity => entity.UserId)
|
||||||
.IsRequired(true);
|
.IsRequired(true);
|
||||||
|
builder
|
||||||
|
.HasOne(entity => entity.UserAddress)
|
||||||
|
.WithMany(entity => entity.UserOrders)
|
||||||
|
.HasForeignKey(entity => entity.UserAddressId)
|
||||||
|
.OnDelete(deleteBehavior: DeleteBehavior.Restrict)
|
||||||
|
.IsRequired(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
472
src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251013044349_u04.Designer.cs
generated
Normal file
472
src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251013044349_u04.Designer.cs
generated
Normal file
@@ -0,0 +1,472 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using CMSMicroservice.Infrastructure.Persistence;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
[Migration("20251013044349_u04")]
|
||||||
|
partial class u04
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("CMS")
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Attempts")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("CodeHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiresAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsUsed")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Mobile")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Purpose")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("OtpTokens", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("ImagePath")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("Price")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Packages", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Roles", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("AvatarPath")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("BirthDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMobileVerified")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRulesAccepted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Mobile")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("MobileVerifiedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("NationalCode")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long?>("ParentId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<bool>("PushNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("ReferralCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("RulesAcceptedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("SmsNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentId");
|
||||||
|
|
||||||
|
b.ToTable("Users", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDefault")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("PostalCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("UserId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserAddresss", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("PackageId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("PaymentDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("PaymentStatus")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<long>("Price")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("TransactionId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("UserAddressId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("UserId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PackageId");
|
||||||
|
|
||||||
|
b.HasIndex("UserAddressId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserOrders", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Created")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LastModified")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("LastModifiedBy")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("RoleId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("UserId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserRoles", "CMS");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent")
|
||||||
|
.WithMany("Users")
|
||||||
|
.HasForeignKey("ParentId");
|
||||||
|
|
||||||
|
b.Navigation("Parent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
|
||||||
|
.WithMany("UserAddresss")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package")
|
||||||
|
.WithMany("UserOrders")
|
||||||
|
.HasForeignKey("PackageId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress")
|
||||||
|
.WithMany("UserOrders")
|
||||||
|
.HasForeignKey("UserAddressId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
|
||||||
|
.WithMany("UserOrders")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Package");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
|
||||||
|
b.Navigation("UserAddress");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role")
|
||||||
|
.WithMany("UserRoles")
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
|
||||||
|
.WithMany("UserRoles")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Role");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UserOrders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UserRoles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UserAddresss");
|
||||||
|
|
||||||
|
b.Navigation("UserOrders");
|
||||||
|
|
||||||
|
b.Navigation("UserRoles");
|
||||||
|
|
||||||
|
b.Navigation("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UserOrders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class u04 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "BirthDate",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users",
|
||||||
|
type: "datetime2",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "EmailNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "PushNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "SmsNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users",
|
||||||
|
type: "bit",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0L);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UserOrders_UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
column: "UserAddressId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_UserOrders_UserAddresss_UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
column: "UserAddressId",
|
||||||
|
principalSchema: "CMS",
|
||||||
|
principalTable: "UserAddresss",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_UserOrders_UserAddresss_UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_UserOrders_UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "BirthDate",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "EmailNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PushNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "SmsNotifications",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UserAddressId",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -162,12 +162,18 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<string>("AvatarPath")
|
b.Property<string>("AvatarPath")
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("BirthDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<DateTime>("Created")
|
b.Property<DateTime>("Created")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("CreatedBy")
|
b.Property<string>("CreatedBy")
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
@@ -202,6 +208,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<long?>("ParentId")
|
b.Property<long?>("ParentId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<bool>("PushNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
b.Property<string>("ReferralCode")
|
b.Property<string>("ReferralCode")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
@@ -209,6 +218,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<DateTime?>("RulesAcceptedAt")
|
b.Property<DateTime?>("RulesAcceptedAt")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("SmsNotifications")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ParentId");
|
b.HasIndex("ParentId");
|
||||||
@@ -305,6 +317,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<long?>("TransactionId")
|
b.Property<long?>("TransactionId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("UserAddressId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.Property<long>("UserId")
|
b.Property<long>("UserId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
@@ -312,6 +327,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
|
|
||||||
b.HasIndex("PackageId");
|
b.HasIndex("PackageId");
|
||||||
|
|
||||||
|
b.HasIndex("UserAddressId");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
b.ToTable("UserOrders", "CMS");
|
b.ToTable("UserOrders", "CMS");
|
||||||
@@ -383,6 +400,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress")
|
||||||
|
.WithMany("UserOrders")
|
||||||
|
.HasForeignKey("UserAddressId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
|
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
|
||||||
.WithMany("UserOrders")
|
.WithMany("UserOrders")
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
@@ -392,6 +415,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Navigation("Package");
|
b.Navigation("Package");
|
||||||
|
|
||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
|
|
||||||
|
b.Navigation("UserAddress");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
|
||||||
@@ -433,6 +458,11 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
|
|
||||||
b.Navigation("Users");
|
b.Navigation("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UserOrders");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.0.116</Version>
|
<Version>0.0.117</Version>
|
||||||
<DebugType>None</DebugType>
|
<DebugType>None</DebugType>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>False</DebugSymbols>
|
||||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ message CreateNewUserRequest
|
|||||||
google.protobuf.StringValue national_code = 4;
|
google.protobuf.StringValue national_code = 4;
|
||||||
google.protobuf.StringValue avatar_path = 5;
|
google.protobuf.StringValue avatar_path = 5;
|
||||||
google.protobuf.Int64Value parent_id = 6;
|
google.protobuf.Int64Value parent_id = 6;
|
||||||
|
bool email_notifications = 7;
|
||||||
|
bool sms_notifications = 8;
|
||||||
|
bool push_notifications = 9;
|
||||||
|
google.protobuf.Timestamp birth_date = 10;
|
||||||
}
|
}
|
||||||
message CreateNewUserResponse
|
message CreateNewUserResponse
|
||||||
{
|
{
|
||||||
@@ -72,6 +76,10 @@ message UpdateUserRequest
|
|||||||
google.protobuf.StringValue avatar_path = 5;
|
google.protobuf.StringValue avatar_path = 5;
|
||||||
bool is_rules_accepted = 6;
|
bool is_rules_accepted = 6;
|
||||||
google.protobuf.Timestamp rules_accepted_at = 7;
|
google.protobuf.Timestamp rules_accepted_at = 7;
|
||||||
|
bool email_notifications = 8;
|
||||||
|
bool sms_notifications = 9;
|
||||||
|
bool push_notifications = 10;
|
||||||
|
google.protobuf.Timestamp birth_date = 11;
|
||||||
}
|
}
|
||||||
message DeleteUserRequest
|
message DeleteUserRequest
|
||||||
{
|
{
|
||||||
@@ -93,6 +101,10 @@ message GetUserResponse
|
|||||||
string referral_code = 8;
|
string referral_code = 8;
|
||||||
bool is_mobile_verified = 9;
|
bool is_mobile_verified = 9;
|
||||||
google.protobuf.Timestamp mobile_verified_at = 10;
|
google.protobuf.Timestamp mobile_verified_at = 10;
|
||||||
|
bool email_notifications = 11;
|
||||||
|
bool sms_notifications = 12;
|
||||||
|
bool push_notifications = 13;
|
||||||
|
google.protobuf.Timestamp birth_date = 14;
|
||||||
}
|
}
|
||||||
message GetAllUserByFilterRequest
|
message GetAllUserByFilterRequest
|
||||||
{
|
{
|
||||||
@@ -112,6 +124,10 @@ message GetAllUserByFilterFilter
|
|||||||
google.protobuf.StringValue referral_code = 8;
|
google.protobuf.StringValue referral_code = 8;
|
||||||
google.protobuf.BoolValue is_mobile_verified = 9;
|
google.protobuf.BoolValue is_mobile_verified = 9;
|
||||||
google.protobuf.Timestamp mobile_verified_at = 10;
|
google.protobuf.Timestamp mobile_verified_at = 10;
|
||||||
|
google.protobuf.BoolValue email_notifications = 11;
|
||||||
|
google.protobuf.BoolValue sms_notifications = 12;
|
||||||
|
google.protobuf.BoolValue push_notifications = 13;
|
||||||
|
google.protobuf.Timestamp birth_date = 14;
|
||||||
}
|
}
|
||||||
message GetAllUserByFilterResponse
|
message GetAllUserByFilterResponse
|
||||||
{
|
{
|
||||||
@@ -130,6 +146,10 @@ message GetAllUserByFilterResponseModel
|
|||||||
string referral_code = 8;
|
string referral_code = 8;
|
||||||
bool is_mobile_verified = 9;
|
bool is_mobile_verified = 9;
|
||||||
google.protobuf.Timestamp mobile_verified_at = 10;
|
google.protobuf.Timestamp mobile_verified_at = 10;
|
||||||
|
bool email_notifications = 11;
|
||||||
|
bool sms_notifications = 12;
|
||||||
|
bool push_notifications = 13;
|
||||||
|
google.protobuf.Timestamp birth_date = 14;
|
||||||
}
|
}
|
||||||
message GetJwtTokenRequest
|
message GetJwtTokenRequest
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ service UserAddressContract
|
|||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
rpc SetAddressAsDefault(SetAddressAsDefaultRequest) returns (google.protobuf.Empty){
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/SetAddressAsDefault"
|
||||||
|
body: "*"
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
message CreateNewUserAddressRequest
|
message CreateNewUserAddressRequest
|
||||||
{
|
{
|
||||||
@@ -116,3 +122,7 @@ message GetAllUserAddressByFilterResponseModel
|
|||||||
bool is_default = 6;
|
bool is_default = 6;
|
||||||
int64 city_id = 7;
|
int64 city_id = 7;
|
||||||
}
|
}
|
||||||
|
message SetAddressAsDefaultRequest
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ message CreateNewUserOrderRequest
|
|||||||
bool payment_status = 4;
|
bool payment_status = 4;
|
||||||
google.protobuf.Timestamp payment_date = 5;
|
google.protobuf.Timestamp payment_date = 5;
|
||||||
int64 user_id = 6;
|
int64 user_id = 6;
|
||||||
|
int64 user_address_id = 7;
|
||||||
}
|
}
|
||||||
message CreateNewUserOrderResponse
|
message CreateNewUserOrderResponse
|
||||||
{
|
{
|
||||||
@@ -66,6 +67,7 @@ message UpdateUserOrderRequest
|
|||||||
bool payment_status = 5;
|
bool payment_status = 5;
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
|
int64 user_address_id = 8;
|
||||||
}
|
}
|
||||||
message DeleteUserOrderRequest
|
message DeleteUserOrderRequest
|
||||||
{
|
{
|
||||||
@@ -84,6 +86,7 @@ message GetUserOrderResponse
|
|||||||
bool payment_status = 5;
|
bool payment_status = 5;
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
|
int64 user_address_id = 8;
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterRequest
|
message GetAllUserOrderByFilterRequest
|
||||||
{
|
{
|
||||||
@@ -100,6 +103,7 @@ message GetAllUserOrderByFilterFilter
|
|||||||
google.protobuf.BoolValue payment_status = 5;
|
google.protobuf.BoolValue payment_status = 5;
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
google.protobuf.Int64Value user_id = 7;
|
google.protobuf.Int64Value user_id = 7;
|
||||||
|
google.protobuf.Int64Value user_address_id = 8;
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterResponse
|
message GetAllUserOrderByFilterResponse
|
||||||
{
|
{
|
||||||
@@ -115,4 +119,5 @@ message GetAllUserOrderByFilterResponseModel
|
|||||||
bool payment_status = 5;
|
bool payment_status = 5;
|
||||||
google.protobuf.Timestamp payment_date = 6;
|
google.protobuf.Timestamp payment_date = 6;
|
||||||
int64 user_id = 7;
|
int64 user_id = 7;
|
||||||
|
int64 user_address_id = 8;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ public class CreateNewUserRequestValidator : AbstractValidator<CreateNewUserRequ
|
|||||||
{
|
{
|
||||||
RuleFor(model => model.Mobile)
|
RuleFor(model => model.Mobile)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
RuleFor(model => model.EmailNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.SmsNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.PushNotifications)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ public class UpdateUserRequestValidator : AbstractValidator<UpdateUserRequest>
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.IsRulesAccepted)
|
RuleFor(model => model.IsRulesAccepted)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.EmailNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.SmsNotifications)
|
||||||
|
.NotNull();
|
||||||
|
RuleFor(model => model.PushNotifications)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||||
|
namespace CMSMicroservice.Protobuf.Validator.UserAddress;
|
||||||
|
|
||||||
|
public class SetAddressAsDefaultRequestValidator : AbstractValidator<SetAddressAsDefaultRequest>
|
||||||
|
{
|
||||||
|
public SetAddressAsDefaultRequestValidator()
|
||||||
|
{
|
||||||
|
RuleFor(model => model.Id)
|
||||||
|
.NotNull();
|
||||||
|
}
|
||||||
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
|
{
|
||||||
|
var result = await ValidateAsync(ValidationContext<SetAddressAsDefaultRequest>.CreateWithOptions((SetAddressAsDefaultRequest)model, x => x.IncludeProperties(propertyName)));
|
||||||
|
if (result.IsValid)
|
||||||
|
return Array.Empty<string>();
|
||||||
|
return result.Errors.Select(e => e.ErrorMessage);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ public class CreateNewUserOrderRequestValidator : AbstractValidator<CreateNewUse
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserAddressId)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public class UpdateUserOrderRequestValidator : AbstractValidator<UpdateUserOrder
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.UserId)
|
RuleFor(model => model.UserId)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
|
RuleFor(model => model.UserAddressId)
|
||||||
|
.NotNull();
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using CMSMicroservice.Application.UserAddressCQ.Commands.UpdateUserAddress;
|
|||||||
using CMSMicroservice.Application.UserAddressCQ.Commands.DeleteUserAddress;
|
using CMSMicroservice.Application.UserAddressCQ.Commands.DeleteUserAddress;
|
||||||
using CMSMicroservice.Application.UserAddressCQ.Queries.GetUserAddress;
|
using CMSMicroservice.Application.UserAddressCQ.Queries.GetUserAddress;
|
||||||
using CMSMicroservice.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
|
using CMSMicroservice.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
|
||||||
|
using CMSMicroservice.Application.UserAddressCQ.Commands.SetAddressAsDefault;
|
||||||
namespace CMSMicroservice.WebApi.Services;
|
namespace CMSMicroservice.WebApi.Services;
|
||||||
public class UserAddressService : UserAddressContract.UserAddressContractBase
|
public class UserAddressService : UserAddressContract.UserAddressContractBase
|
||||||
{
|
{
|
||||||
@@ -34,4 +35,8 @@ public class UserAddressService : UserAddressContract.UserAddressContractBase
|
|||||||
{
|
{
|
||||||
return await _dispatchRequestToCQRS.Handle<GetAllUserAddressByFilterRequest, GetAllUserAddressByFilterQuery, GetAllUserAddressByFilterResponse>(request, context);
|
return await _dispatchRequestToCQRS.Handle<GetAllUserAddressByFilterRequest, GetAllUserAddressByFilterQuery, GetAllUserAddressByFilterResponse>(request, context);
|
||||||
}
|
}
|
||||||
|
public override async Task<Empty> SetAddressAsDefault(SetAddressAsDefaultRequest request, ServerCallContext context)
|
||||||
|
{
|
||||||
|
return await _dispatchRequestToCQRS.Handle<SetAddressAsDefaultRequest, SetAddressAsDefaultCommand>(request, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user