Compare commits
2 Commits
acd24336b2
...
27a6b10edf
Author | SHA1 | Date |
---|---|---|
|
27a6b10edf | |
|
aae924e77b |
|
@ -31,9 +31,18 @@
|
|||
"FirstName": "همه کاره",
|
||||
"LastName": "سیستم"
|
||||
},
|
||||
"Manager": {
|
||||
"Username": "09128387004",
|
||||
"Email": "mahanmasiha6@gmail.com",
|
||||
"Password": "eF79o4P4BopCUbUK",
|
||||
"Phone": "09128387004",
|
||||
"RoleName": "Manager",
|
||||
"FirstName": "ماهان",
|
||||
"LastName": ""
|
||||
},
|
||||
"StorageSetting": {
|
||||
"AccessKey": "d37a1cc6acfea3a6f92c538ef0f6601f1edcdc9143942b6470e5d1032aa6bfe2",
|
||||
"SecretKey": "979313b7-30fb-40ff-94d8-d0390d3fa876",
|
||||
"AccessKey": "979313b7-30fb-40ff-94d8-d0390d3fa876",
|
||||
"SecretKey": "d37a1cc6acfea3a6f92c538ef0f6601f1edcdc9143942b6470e5d1032aa6bfe2",
|
||||
"BucketKey": "vesmeh-content"
|
||||
},
|
||||
"JwtSettings": {
|
||||
|
|
|
@ -184,7 +184,6 @@ public static class ServiceExtensions
|
|||
}).AddEntityFrameworkStores<ApplicationContext>()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddErrorDescriber<PersianIdentityErrorDescriber>();
|
||||
;
|
||||
}
|
||||
|
||||
public static void AddCustomApiVersioning(this IServiceCollection serviceCollection)
|
||||
|
|
|
@ -10,7 +10,7 @@ public class AccountService : IAccountService
|
|||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IManagerUserService _managerUserService;
|
||||
|
||||
public AccountService(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
|
@ -19,7 +19,7 @@ public class AccountService : IAccountService
|
|||
ICurrentUserService currentUserService,
|
||||
IRepositoryWrapper repositoryWrapper,
|
||||
ISmsService smsService,
|
||||
IUserService userService)
|
||||
IManagerUserService managerUserService)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_userSignInManager = userSignInManager;
|
||||
|
@ -27,7 +27,7 @@ public class AccountService : IAccountService
|
|||
_currentUserService = currentUserService;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_smsService = smsService;
|
||||
_userService = userService;
|
||||
_managerUserService = managerUserService;
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class AccountService : IAccountService
|
|||
throw new AppException("شماره تلفن ارسالی اشتباه است");
|
||||
var user = await _userManager.FindByNameAsync(newPhoneNumber);
|
||||
if (user == null)
|
||||
user = await _userService.CreateUserAsync(phoneNumber);
|
||||
user = await _managerUserService.CreateManagerAsync(phoneNumber);
|
||||
|
||||
var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone");
|
||||
await _smsService.SendVerifyCodeAsync(newPhoneNumber, token);
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrderDiscountCommand , double>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CalculateOrderDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public CalculateOrderDiscountCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<double> Handle(CalculateOrderDiscountCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -20,6 +22,27 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
if (discount == null)
|
||||
throw new AppException("تخفیف وجود منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
|
||||
|
||||
if (_currentUserService.UserId != null && Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
||||
{
|
||||
var discountedUserOrder = await _repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(f => f.UserId == userId && f.DiscountCode == discount.Code, cancellationToken);
|
||||
if (discountedUserOrder != null)
|
||||
throw new AppException("شما یک بار از این کد تخفیف استفاده کرده اید", ApiResultStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
if (discount.IsForFirstPurchase)
|
||||
{
|
||||
if (_currentUserService.UserId != null && Guid.TryParse(_currentUserService.UserId, out Guid firstPurchaseUserId))
|
||||
{
|
||||
var userOrderCount = await _repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.CountAsync(f => f.UserId == firstPurchaseUserId && f.DiscountCode == discount.Code, cancellationToken);
|
||||
if (userOrderCount > 0)
|
||||
throw new AppException("شما قبلا خریدی داشته اید و نمیتوانید از تخفیف اولین خرید استفاده کنید", ApiResultStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
double discountPrice = 0;
|
||||
double totalPrice = 0;
|
||||
if (discount.Type == DiscountType.All)
|
||||
|
|
|
@ -7,16 +7,19 @@ public class UserService : IUserService
|
|||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly RoleManager<ApplicationRole> _roleManager;
|
||||
private readonly IExternalFilesService _externalFilesService;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public UserService(ICurrentUserService currentUserService,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
RoleManager<ApplicationRole> roleManager,
|
||||
IExternalFilesService externalFilesService)
|
||||
IExternalFilesService externalFilesService,
|
||||
IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_currentUserService = currentUserService;
|
||||
_userManager = userManager;
|
||||
_roleManager = roleManager;
|
||||
_externalFilesService = externalFilesService;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,14 +261,21 @@ public class UserService : IUserService
|
|||
if (user == null)
|
||||
throw new AppException("User NotFound", ApiResultStatusCode.NotFound);
|
||||
|
||||
var manager = await _repositoryWrapper.SetRepository<Manager>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(m => m.UserId == userId, cancellationToken);
|
||||
|
||||
var currentVersion = await _externalFilesService.GetAdminChangeLogAsync(cancellationToken);
|
||||
|
||||
if (!(user.LatestVersionUsed < currentVersion.VersionNumber)) return currentVersion;
|
||||
|
||||
currentVersion.IsNewVersion = true;
|
||||
user.LatestVersionUsed = currentVersion.VersionNumber;
|
||||
await _userManager.UpdateAsync(user);
|
||||
if (manager != null)
|
||||
{
|
||||
if (!(manager.LatestVersionUsed < currentVersion.VersionNumber)) return currentVersion;
|
||||
currentVersion.IsNewVersion = true;
|
||||
manager.LatestVersionUsed = currentVersion.VersionNumber;
|
||||
_repositoryWrapper.SetRepository<Manager>()
|
||||
.Update(manager);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
return currentVersion;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
namespace NetinaShop.Domain.CommandQueries.Commands;
|
||||
|
||||
public sealed record CreateDiscountCommand(string Code,
|
||||
string Description,
|
||||
int DiscountPercent,
|
||||
long DiscountAmount,
|
||||
bool HasCode,
|
||||
|
@ -18,12 +19,14 @@ bool IsInfinity,
|
|||
long UseCount,
|
||||
bool IsForInvitation,
|
||||
bool IsSpecialOffer,
|
||||
bool IsForFirstPurchase,
|
||||
Guid ProductId,
|
||||
Guid CategoryId) : IRequest<DiscountLDto>;
|
||||
|
||||
public sealed record UpdateDiscountCommand(
|
||||
Guid Id,
|
||||
string Code,
|
||||
string Description,
|
||||
int DiscountPercent,
|
||||
long DiscountAmount,
|
||||
bool HasCode,
|
||||
|
@ -41,6 +44,7 @@ public sealed record UpdateDiscountCommand(
|
|||
long UseCount,
|
||||
bool IsForInvitation,
|
||||
bool IsSpecialOffer,
|
||||
bool IsForFirstPurchase,
|
||||
Guid ProductId,
|
||||
Guid CategoryId) : IRequest<bool>;
|
||||
|
||||
|
@ -48,4 +52,4 @@ public sealed record CreateSaleCooperationDiscount(Guid CorporateUserId) : IRequ
|
|||
|
||||
public sealed record DeleteDiscountCommand(Guid Id) : IRequest<bool>;
|
||||
|
||||
public sealed record CalculateOrderDiscountCommand(string DiscountCode,Order Order) : IRequest<double>;
|
||||
public sealed record CalculateOrderDiscountCommand(string DiscountCode, Order Order) : IRequest<double>;
|
|
@ -3,6 +3,7 @@
|
|||
public class DiscountLDto : BaseDto<DiscountLDto,Discount>
|
||||
{
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int DiscountPercent { get; set; }
|
||||
public long DiscountAmount { get; set; }
|
||||
public bool HasCode { get; set; }
|
||||
|
@ -24,4 +25,5 @@ public class DiscountLDto : BaseDto<DiscountLDto,Discount>
|
|||
public string ProductName { get; set; } = string.Empty;
|
||||
public Guid CategoryId { get; set; }
|
||||
public string CategoryName { get; set; } = string.Empty;
|
||||
public bool IsForFirstPurchase { get; set; }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class CustomerSDto : BaseDto<CustomerSDto, Customer>
|
||||
{
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
public string FullName => FirstName + " " + LastName;
|
||||
|
||||
public List<Guid> RoleIds { get; set; } = new();
|
||||
public long BirthDateTimeStamp => DateTimeExtensions.DateTimeToUnixTimeStamp(BirthDate);
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
public class DiscountSDto : BaseDto<DiscountSDto,Discount>
|
||||
{
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int DiscountPercent { get; set; }
|
||||
public long DiscountAmount { get; set; }
|
||||
public bool HasCode { get; set; }
|
||||
|
@ -19,4 +20,5 @@ public class DiscountSDto : BaseDto<DiscountSDto,Discount>
|
|||
public long UseCount { get; set; }
|
||||
public bool IsSpecialOffer { get; set; }
|
||||
public bool IsForInvitation { get; set; }
|
||||
public bool IsForFirstPurchase { get; set; }
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class ManagerSDto : BaseDto<ManagerSDto, Manager>
|
||||
{
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public double LatestVersionUsed { get; set; }
|
||||
|
||||
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
public string FullName => FirstName + " " + LastName;
|
||||
|
||||
public List<Guid> RoleIds { get; set; } = new();
|
||||
public long BirthDateTimeStamp => DateTimeExtensions.DateTimeToUnixTimeStamp(BirthDate);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class MarketerSDto : BaseDto<MarketerSDto, Marketer>
|
||||
{
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string Shaba { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
public string FullName => FirstName + " " + LastName;
|
||||
|
||||
public List<Guid> RoleIds { get; set; } = new();
|
||||
public long BirthDateTimeStamp => DateTimeExtensions.DateTimeToUnixTimeStamp(BirthDate);
|
||||
}
|
|
@ -9,9 +9,12 @@ public partial class CategoryDiscount : Discount
|
|||
|
||||
}
|
||||
|
||||
public CategoryDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count,bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer, Guid categoryId)
|
||||
: base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount,
|
||||
isForInvitation, isSpecialOffer, immortal)
|
||||
public CategoryDiscount(string code, string description, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type,
|
||||
int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling,
|
||||
bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,
|
||||
bool isForFirstPurchase, bool isSpecialOffer , Guid categoryId)
|
||||
: base(code, description, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount,
|
||||
isForInvitation, isSpecialOffer,isForFirstPurchase, immortal)
|
||||
{
|
||||
CategoryId = categoryId;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
public partial class Discount
|
||||
{
|
||||
public static Discount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count,bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer)
|
||||
public static Discount Create(string code,string description, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type,
|
||||
int count,bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling,
|
||||
bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,
|
||||
bool isForFirstPurchase, bool isSpecialOffer)
|
||||
{
|
||||
return new Discount(code,
|
||||
description,
|
||||
discountPercent,
|
||||
discountAmount,
|
||||
hasCode,
|
||||
|
@ -21,6 +25,7 @@ public partial class Discount
|
|||
useCount,
|
||||
isForInvitation,
|
||||
isSpecialOffer,
|
||||
isForFirstPurchase,
|
||||
immortal);
|
||||
}
|
||||
|
||||
|
@ -36,20 +41,26 @@ public partial class Discount
|
|||
|
||||
public partial class ProductDiscount
|
||||
{
|
||||
public static ProductDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation ,bool isSpecialOffer, Guid productId)
|
||||
public static ProductDiscount Create(string code, string description, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type,
|
||||
int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling,
|
||||
bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,
|
||||
bool isForFirstPurchase, bool isSpecialOffer, Guid productId)
|
||||
{
|
||||
return new ProductDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count,immortal, startDate,
|
||||
return new ProductDiscount(code,description, discountPercent, discountAmount, hasCode, amountType, type, count,immortal, startDate,
|
||||
expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount,
|
||||
isForInvitation, isSpecialOffer, productId);
|
||||
isForInvitation, isForFirstPurchase, isSpecialOffer, productId);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CategoryDiscount
|
||||
{
|
||||
public static CategoryDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, bool isSpecialOffer, Guid categoryId)
|
||||
public static CategoryDiscount Create(string code, string description, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type,
|
||||
int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling,
|
||||
bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,
|
||||
bool isForFirstPurchase, bool isSpecialOffer, Guid categoryId)
|
||||
{
|
||||
return new CategoryDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count,immortal, startDate,
|
||||
return new CategoryDiscount(code,description, discountPercent, discountAmount, hasCode, amountType, type, count,immortal, startDate,
|
||||
expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount,
|
||||
isForInvitation,isSpecialOffer, categoryId);
|
||||
isForInvitation, isForFirstPurchase,isSpecialOffer, categoryId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public partial class Discount : ApiEntity
|
|||
}
|
||||
|
||||
public Discount(string code,
|
||||
string description,
|
||||
int discountPercent,
|
||||
long discountAmount,
|
||||
bool hasCode,
|
||||
|
@ -29,9 +30,11 @@ public partial class Discount : ApiEntity
|
|||
long useCount,
|
||||
bool isForInvitation,
|
||||
bool isSpecialOffer,
|
||||
bool isForFirstPurchase,
|
||||
bool immortal)
|
||||
{
|
||||
Code = code;
|
||||
Description = description;
|
||||
DiscountPercent = discountPercent;
|
||||
DiscountAmount = discountAmount;
|
||||
HasCode = hasCode;
|
||||
|
@ -48,9 +51,11 @@ public partial class Discount : ApiEntity
|
|||
UseCount = useCount;
|
||||
IsForInvitation = isForInvitation;
|
||||
IsSpecialOffer = isSpecialOffer;
|
||||
IsForFirstPurchase = isForFirstPurchase;
|
||||
Immortal = immortal;
|
||||
}
|
||||
public string Code { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
public int DiscountPercent { get; internal set; }
|
||||
public long DiscountAmount { get; internal set; }
|
||||
public bool HasCode { get; internal set; }
|
||||
|
@ -69,6 +74,7 @@ public partial class Discount : ApiEntity
|
|||
public bool IsSpecialOffer { get; internal set; }
|
||||
public bool IsForInvitation { get; internal set; }
|
||||
public bool IsForSaleCooperation { get; internal set; }
|
||||
public bool IsForFirstPurchase { get; internal set; }
|
||||
|
||||
|
||||
public Guid? CorporateUserId { get; internal set; }
|
||||
|
|
|
@ -7,8 +7,12 @@ public partial class ProductDiscount : Discount
|
|||
|
||||
}
|
||||
|
||||
public ProductDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer,Guid productId)
|
||||
: base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, isForInvitation, isSpecialOffer, immortal)
|
||||
public ProductDiscount(string code, string description, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type,
|
||||
int count, bool immortal, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling,
|
||||
bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,
|
||||
bool isForFirstPurchase, bool isSpecialOffer,Guid productId)
|
||||
: base(code,description, discountPercent, discountAmount, hasCode, amountType, type, count, startDate,
|
||||
expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, isForInvitation, isSpecialOffer,isForFirstPurchase, immortal)
|
||||
{
|
||||
ProductId = productId;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public partial class Order : ApiEntity
|
|||
public string DiscountCode { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid UserId { get; internal set; }
|
||||
public ApplicationUser? User { get; internal set; }
|
||||
public Customer? User { get; internal set; }
|
||||
|
||||
public OrderDelivery? OrderDelivery { get; set; }
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ public class ApplicationUser : IdentityUser<Guid>
|
|||
public string LastName { get; set; } = string.Empty;
|
||||
public string NationalId { get; set; } = string.Empty;
|
||||
|
||||
public double LatestVersionUsed { get; set; }
|
||||
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public SignUpStatus SignUpStatus { get; set; }
|
||||
|
||||
public List<UserAddress> Addresses { get; set; } = new();
|
||||
public Manager? Manager { get; set; }
|
||||
public Customer? Customer { get; set; }
|
||||
public Marketer? Marketer { get; set; }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace NetinaShop.Domain.Entities.Users;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
|
||||
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class Customer : ApiEntity
|
||||
{
|
||||
public List<UserAddress> Addresses { get; set; } = new();
|
||||
public Guid UserId { get; set; }
|
||||
public ApplicationUser? User { get; set; }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace NetinaShop.Domain.Entities.Users;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
|
||||
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class Manager : ApiEntity
|
||||
{
|
||||
public double LatestVersionUsed { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public ApplicationUser? User { get; set; }
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
namespace NetinaShop.Domain.Entities.Users;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
|
||||
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class Marketer : ApiEntity
|
||||
{
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string Shaba { get; set; } = string.Empty;
|
||||
public Guid UserId { get; set; }
|
||||
public ApplicationUser? User { get; set; }
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
public enum DiscountType
|
||||
{
|
||||
[Display(Name = "همه اقلام")]
|
||||
All,
|
||||
All = 0,
|
||||
[Display(Name = "محصولی")]
|
||||
Product,
|
||||
Product = 1,
|
||||
[Display(Name = "دسته ای")]
|
||||
Category,
|
||||
Category = 2,
|
||||
[Display(Name = "مشترکی")]
|
||||
Subscriber
|
||||
Subscriber = 3
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace NetinaShop.Domain.Mappers
|
||||
{
|
||||
public static partial class CustomerMapper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
return p1 == null ? null : new Discount()
|
||||
{
|
||||
Code = p1.Code,
|
||||
Description = p1.Description,
|
||||
DiscountPercent = p1.DiscountPercent,
|
||||
DiscountAmount = p1.DiscountAmount,
|
||||
HasCode = p1.HasCode,
|
||||
|
@ -30,6 +31,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p1.UseCount,
|
||||
IsSpecialOffer = p1.IsSpecialOffer,
|
||||
IsForInvitation = p1.IsForInvitation,
|
||||
IsForFirstPurchase = p1.IsForFirstPurchase,
|
||||
Id = p1.Id,
|
||||
CreatedAt = p1.CreatedAt
|
||||
};
|
||||
|
@ -43,6 +45,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
Discount result = p3 ?? new Discount();
|
||||
|
||||
result.Code = p2.Code;
|
||||
result.Description = p2.Description;
|
||||
result.DiscountPercent = p2.DiscountPercent;
|
||||
result.DiscountAmount = p2.DiscountAmount;
|
||||
result.HasCode = p2.HasCode;
|
||||
|
@ -60,6 +63,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.UseCount = p2.UseCount;
|
||||
result.IsSpecialOffer = p2.IsSpecialOffer;
|
||||
result.IsForInvitation = p2.IsForInvitation;
|
||||
result.IsForFirstPurchase = p2.IsForFirstPurchase;
|
||||
result.Id = p2.Id;
|
||||
result.CreatedAt = p2.CreatedAt;
|
||||
return result;
|
||||
|
@ -68,6 +72,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
public static Expression<Func<DiscountLDto, Discount>> ProjectToDiscount => p4 => new Discount()
|
||||
{
|
||||
Code = p4.Code,
|
||||
Description = p4.Description,
|
||||
DiscountPercent = p4.DiscountPercent,
|
||||
DiscountAmount = p4.DiscountAmount,
|
||||
HasCode = p4.HasCode,
|
||||
|
@ -85,6 +90,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p4.UseCount,
|
||||
IsSpecialOffer = p4.IsSpecialOffer,
|
||||
IsForInvitation = p4.IsForInvitation,
|
||||
IsForFirstPurchase = p4.IsForFirstPurchase,
|
||||
Id = p4.Id,
|
||||
CreatedAt = p4.CreatedAt
|
||||
};
|
||||
|
@ -93,6 +99,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
return p5 == null ? null : new DiscountLDto()
|
||||
{
|
||||
Code = p5.Code,
|
||||
Description = p5.Description,
|
||||
DiscountPercent = p5.DiscountPercent,
|
||||
DiscountAmount = p5.DiscountAmount,
|
||||
HasCode = p5.HasCode,
|
||||
|
@ -110,6 +117,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p5.UseCount,
|
||||
IsSpecialOffer = p5.IsSpecialOffer,
|
||||
IsForInvitation = p5.IsForInvitation,
|
||||
IsForFirstPurchase = p5.IsForFirstPurchase,
|
||||
Id = p5.Id,
|
||||
CreatedAt = p5.CreatedAt
|
||||
};
|
||||
|
@ -123,6 +131,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
DiscountLDto result = p7 ?? new DiscountLDto();
|
||||
|
||||
result.Code = p6.Code;
|
||||
result.Description = p6.Description;
|
||||
result.DiscountPercent = p6.DiscountPercent;
|
||||
result.DiscountAmount = p6.DiscountAmount;
|
||||
result.HasCode = p6.HasCode;
|
||||
|
@ -140,6 +149,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.UseCount = p6.UseCount;
|
||||
result.IsSpecialOffer = p6.IsSpecialOffer;
|
||||
result.IsForInvitation = p6.IsForInvitation;
|
||||
result.IsForFirstPurchase = p6.IsForFirstPurchase;
|
||||
result.Id = p6.Id;
|
||||
result.CreatedAt = p6.CreatedAt;
|
||||
return result;
|
||||
|
@ -148,6 +158,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
public static Expression<Func<Discount, DiscountLDto>> ProjectToLDto => p8 => new DiscountLDto()
|
||||
{
|
||||
Code = p8.Code,
|
||||
Description = p8.Description,
|
||||
DiscountPercent = p8.DiscountPercent,
|
||||
DiscountAmount = p8.DiscountAmount,
|
||||
HasCode = p8.HasCode,
|
||||
|
@ -165,6 +176,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p8.UseCount,
|
||||
IsSpecialOffer = p8.IsSpecialOffer,
|
||||
IsForInvitation = p8.IsForInvitation,
|
||||
IsForFirstPurchase = p8.IsForFirstPurchase,
|
||||
Id = p8.Id,
|
||||
CreatedAt = p8.CreatedAt
|
||||
};
|
||||
|
@ -173,6 +185,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
return p9 == null ? null : new Discount()
|
||||
{
|
||||
Code = p9.Code,
|
||||
Description = p9.Description,
|
||||
DiscountPercent = p9.DiscountPercent,
|
||||
DiscountAmount = p9.DiscountAmount,
|
||||
HasCode = p9.HasCode,
|
||||
|
@ -189,6 +202,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p9.UseCount,
|
||||
IsSpecialOffer = p9.IsSpecialOffer,
|
||||
IsForInvitation = p9.IsForInvitation,
|
||||
IsForFirstPurchase = p9.IsForFirstPurchase,
|
||||
Id = p9.Id,
|
||||
CreatedAt = p9.CreatedAt
|
||||
};
|
||||
|
@ -202,6 +216,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
Discount result = p11 ?? new Discount();
|
||||
|
||||
result.Code = p10.Code;
|
||||
result.Description = p10.Description;
|
||||
result.DiscountPercent = p10.DiscountPercent;
|
||||
result.DiscountAmount = p10.DiscountAmount;
|
||||
result.HasCode = p10.HasCode;
|
||||
|
@ -218,6 +233,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.UseCount = p10.UseCount;
|
||||
result.IsSpecialOffer = p10.IsSpecialOffer;
|
||||
result.IsForInvitation = p10.IsForInvitation;
|
||||
result.IsForFirstPurchase = p10.IsForFirstPurchase;
|
||||
result.Id = p10.Id;
|
||||
result.CreatedAt = p10.CreatedAt;
|
||||
return result;
|
||||
|
@ -228,6 +244,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
return p12 == null ? null : new DiscountSDto()
|
||||
{
|
||||
Code = p12.Code,
|
||||
Description = p12.Description,
|
||||
DiscountPercent = p12.DiscountPercent,
|
||||
DiscountAmount = p12.DiscountAmount,
|
||||
HasCode = p12.HasCode,
|
||||
|
@ -244,6 +261,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p12.UseCount,
|
||||
IsSpecialOffer = p12.IsSpecialOffer,
|
||||
IsForInvitation = p12.IsForInvitation,
|
||||
IsForFirstPurchase = p12.IsForFirstPurchase,
|
||||
Id = p12.Id,
|
||||
CreatedAt = p12.CreatedAt
|
||||
};
|
||||
|
@ -257,6 +275,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
DiscountSDto result = p14 ?? new DiscountSDto();
|
||||
|
||||
result.Code = p13.Code;
|
||||
result.Description = p13.Description;
|
||||
result.DiscountPercent = p13.DiscountPercent;
|
||||
result.DiscountAmount = p13.DiscountAmount;
|
||||
result.HasCode = p13.HasCode;
|
||||
|
@ -273,6 +292,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.UseCount = p13.UseCount;
|
||||
result.IsSpecialOffer = p13.IsSpecialOffer;
|
||||
result.IsForInvitation = p13.IsForInvitation;
|
||||
result.IsForFirstPurchase = p13.IsForFirstPurchase;
|
||||
result.Id = p13.Id;
|
||||
result.CreatedAt = p13.CreatedAt;
|
||||
return result;
|
||||
|
@ -281,6 +301,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
public static Expression<Func<Discount, DiscountSDto>> ProjectToSDto => p15 => new DiscountSDto()
|
||||
{
|
||||
Code = p15.Code,
|
||||
Description = p15.Description,
|
||||
DiscountPercent = p15.DiscountPercent,
|
||||
DiscountAmount = p15.DiscountAmount,
|
||||
HasCode = p15.HasCode,
|
||||
|
@ -297,6 +318,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
UseCount = p15.UseCount,
|
||||
IsSpecialOffer = p15.IsSpecialOffer,
|
||||
IsForInvitation = p15.IsForInvitation,
|
||||
IsForFirstPurchase = p15.IsForFirstPurchase,
|
||||
Id = p15.Id,
|
||||
CreatedAt = p15.CreatedAt
|
||||
};
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using NetinaShop.Domain.Dtos.SmallDtos;
|
||||
using NetinaShop.Domain.Entities.Users;
|
||||
|
||||
namespace NetinaShop.Domain.Mappers
|
||||
{
|
||||
public static partial class ManagerMapper
|
||||
{
|
||||
public static Manager AdaptToManager(this ManagerSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new Manager()
|
||||
{
|
||||
LatestVersionUsed = p1.LatestVersionUsed,
|
||||
FirstName = p1.FirstName,
|
||||
LastName = p1.LastName,
|
||||
NationalId = p1.NationalId,
|
||||
BirthDate = p1.BirthDate,
|
||||
Gender = p1.Gender,
|
||||
SignUpStatus = p1.SignUpStatus,
|
||||
Id = p1.Id,
|
||||
Email = p1.Email,
|
||||
PhoneNumber = p1.PhoneNumber
|
||||
};
|
||||
}
|
||||
public static Manager AdaptTo(this ManagerSDto p2, Manager p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Manager result = p3 ?? new Manager();
|
||||
|
||||
result.LatestVersionUsed = p2.LatestVersionUsed;
|
||||
result.FirstName = p2.FirstName;
|
||||
result.LastName = p2.LastName;
|
||||
result.NationalId = p2.NationalId;
|
||||
result.BirthDate = p2.BirthDate;
|
||||
result.Gender = p2.Gender;
|
||||
result.SignUpStatus = p2.SignUpStatus;
|
||||
result.Id = p2.Id;
|
||||
result.Email = p2.Email;
|
||||
result.PhoneNumber = p2.PhoneNumber;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static ManagerSDto AdaptToSDto(this Manager p4)
|
||||
{
|
||||
return p4 == null ? null : new ManagerSDto()
|
||||
{
|
||||
PhoneNumber = p4.PhoneNumber,
|
||||
FirstName = p4.FirstName,
|
||||
LastName = p4.LastName,
|
||||
BirthDate = p4.BirthDate,
|
||||
Gender = p4.Gender,
|
||||
SignUpStatus = p4.SignUpStatus,
|
||||
NationalId = p4.NationalId,
|
||||
Email = p4.Email,
|
||||
LatestVersionUsed = p4.LatestVersionUsed,
|
||||
Id = p4.Id
|
||||
};
|
||||
}
|
||||
public static ManagerSDto AdaptTo(this Manager p5, ManagerSDto p6)
|
||||
{
|
||||
if (p5 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ManagerSDto result = p6 ?? new ManagerSDto();
|
||||
|
||||
result.PhoneNumber = p5.PhoneNumber;
|
||||
result.FirstName = p5.FirstName;
|
||||
result.LastName = p5.LastName;
|
||||
result.BirthDate = p5.BirthDate;
|
||||
result.Gender = p5.Gender;
|
||||
result.SignUpStatus = p5.SignUpStatus;
|
||||
result.NationalId = p5.NationalId;
|
||||
result.Email = p5.Email;
|
||||
result.LatestVersionUsed = p5.LatestVersionUsed;
|
||||
result.Id = p5.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Manager, ManagerSDto>> ProjectToSDto => p7 => new ManagerSDto()
|
||||
{
|
||||
PhoneNumber = p7.PhoneNumber,
|
||||
FirstName = p7.FirstName,
|
||||
LastName = p7.LastName,
|
||||
BirthDate = p7.BirthDate,
|
||||
Gender = p7.Gender,
|
||||
SignUpStatus = p7.SignUpStatus,
|
||||
NationalId = p7.NationalId,
|
||||
Email = p7.Email,
|
||||
LatestVersionUsed = p7.LatestVersionUsed,
|
||||
Id = p7.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace NetinaShop.Domain.Mappers
|
||||
{
|
||||
public static partial class MarketerMapper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -79,5 +79,44 @@ public class MapsterRegister : IRegister
|
|||
.IgnoreNullValues(false)
|
||||
.TwoWays();
|
||||
|
||||
ConfigUserMappers(config);
|
||||
|
||||
}
|
||||
|
||||
private void ConfigUserMappers(TypeAdapterConfig config)
|
||||
{
|
||||
|
||||
config.NewConfig<Manager, ManagerSDto>()
|
||||
.Map("PhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty)
|
||||
.Map("FirstName", o => o.User != null ? o.User.FirstName : string.Empty)
|
||||
.Map("LastName", o => o.User != null ? o.User.LastName : string.Empty)
|
||||
.Map("BirthDate", o => o.User != null ? o.User.BirthDate : DateTime.MinValue)
|
||||
.Map("Gender", o => o.User != null ? o.User.Gender : 0)
|
||||
.Map("SignUpStatus", o => o.User != null ? o.User.SignUpStatus : 0)
|
||||
.Map("NationalId", o => o.User != null ? o.User.NationalId : string.Empty)
|
||||
.Map("Email", o => o.User != null ? o.User.Email : string.Empty)
|
||||
.TwoWays();
|
||||
|
||||
config.NewConfig<Marketer, MarketerSDto>()
|
||||
.Map("PhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty)
|
||||
.Map("FirstName", o => o.User != null ? o.User.FirstName : string.Empty)
|
||||
.Map("LastName", o => o.User != null ? o.User.LastName : string.Empty)
|
||||
.Map("BirthDate", o => o.User != null ? o.User.BirthDate : DateTime.MinValue)
|
||||
.Map("Gender", o => o.User != null ? o.User.Gender : 0)
|
||||
.Map("SignUpStatus", o => o.User != null ? o.User.SignUpStatus : 0)
|
||||
.Map("NationalId", o => o.User != null ? o.User.NationalId : string.Empty)
|
||||
.Map("Email", o => o.User != null ? o.User.Email : string.Empty)
|
||||
.TwoWays();
|
||||
|
||||
config.NewConfig<Customer, CustomerSDto>()
|
||||
.Map("PhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty)
|
||||
.Map("FirstName", o => o.User != null ? o.User.FirstName : string.Empty)
|
||||
.Map("LastName", o => o.User != null ? o.User.LastName : string.Empty)
|
||||
.Map("BirthDate", o => o.User != null ? o.User.BirthDate : DateTime.MinValue)
|
||||
.Map("Gender", o => o.User != null ? o.User.Gender : 0)
|
||||
.Map("SignUpStatus", o => o.User != null ? o.User.SignUpStatus : 0)
|
||||
.Map("NationalId", o => o.User != null ? o.User.NationalId : string.Empty)
|
||||
.Map("Email", o => o.User != null ? o.User.Email : string.Empty)
|
||||
.TwoWays();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ public class SiteSettings
|
|||
public string StorageBaseUrl { get; set; } = string.Empty;
|
||||
public RedisSettings MasterRedisConfiguration { get; set; } = new RedisSettings();
|
||||
public UserSetting UserSetting { get; set; } = new UserSetting();
|
||||
public UserSetting Manager { get; set; } = new UserSetting();
|
||||
public string KaveNegarApiKey { get; set; } = string.Empty;
|
||||
public StorageSettings StorageSetting { get; set; } = new StorageSettings();
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
<PackageReference Include="Mapster.Core" Version="1.2.1" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Mapster.Core" Version="1.2.0" />
|
||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.3" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
|
|
|
@ -13,29 +13,32 @@ public class CreateDiscountCommandHandler : IRequestHandler<CreateDiscountComman
|
|||
switch (request.Type)
|
||||
{
|
||||
case DiscountType.All:
|
||||
var ent = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation,request.IsSpecialOffer);
|
||||
var ent = Discount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount,
|
||||
request.HasCode, request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate,
|
||||
request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling,
|
||||
request.IsInfinity, request.UseCount, request.IsForInvitation,request.IsForFirstPurchase,request.IsSpecialOffer);
|
||||
_repositoryWrapper.SetRepository<Discount>().Add(ent);
|
||||
break;
|
||||
case DiscountType.Category:
|
||||
var catDis = CategoryDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
var catDis = CategoryDiscount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
||||
request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||
request.IsForInvitation,request.IsSpecialOffer, request.CategoryId);
|
||||
request.IsForInvitation,request.IsForFirstPurchase,request.IsSpecialOffer, request.CategoryId);
|
||||
_repositoryWrapper.SetRepository<CategoryDiscount>().Add(catDis);
|
||||
break;
|
||||
|
||||
case DiscountType.Product:
|
||||
var productDis = ProductDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
var productDis = ProductDiscount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
||||
request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||
request.IsForInvitation, request.IsSpecialOffer,request.ProductId);
|
||||
request.IsForInvitation,request.IsForFirstPurchase, request.IsSpecialOffer,request.ProductId);
|
||||
_repositoryWrapper.SetRepository<ProductDiscount>().Add(productDis);
|
||||
break;
|
||||
default:
|
||||
var def = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
var def = Discount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
||||
request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||
request.IsForInvitation,request.IsSpecialOffer);
|
||||
request.IsForInvitation, request.IsForFirstPurchase,request.IsSpecialOffer);
|
||||
_repositoryWrapper.SetRepository<Discount>().Add(def);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ public class CreateSaleCooperationDiscountHandler : IRequestHandler<CreateSaleCo
|
|||
if (foundedDiscount == null)
|
||||
{
|
||||
var code = StringExtensions.GetId();
|
||||
foundedDiscount = Discount.Create(code, 10, 0, true,
|
||||
foundedDiscount = Discount.Create(code,$"کد مخصوص همکاری در فروش برای کاربر - {user.FirstName} {user.LastName}", 10, 0, true,
|
||||
DiscountAmountType.Percent, DiscountType.All, 0, true, DateTime.Today, DateTime.Today.AddYears(10), 0,
|
||||
false, 0, false, true, 0, false, false);
|
||||
false, 0, false, true, 0, false, false,false);
|
||||
foundedDiscount.SetCorporate(userId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Discount>().Add(foundedDiscount);
|
||||
|
|
|
@ -12,11 +12,12 @@ public class GetDiscountsQueryHandler : IRequestHandler<GetDiscountsQuery, List<
|
|||
}
|
||||
public async Task<List<DiscountSDto>> Handle(GetDiscountsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _repositoryWrapper.SetRepository<Discount>().TableNoTracking
|
||||
var discounts = await _repositoryWrapper.SetRepository<Discount>().TableNoTracking
|
||||
.Where(d=>!d.IsSpecialOffer)
|
||||
.OrderByDescending(b => b.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(DiscountMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
return discounts;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,12 @@ public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountComman
|
|||
var ent = await _repositoryWrapper.SetRepository<Discount>().TableNoTracking.FirstOrDefaultAsync(d=>d.Id==request.Id,cancellationToken);
|
||||
if (ent == null)
|
||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||
var newEnt = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation, request.IsSpecialOffer);
|
||||
var newEnt = Discount.Create(request.Code,request.Description,
|
||||
request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count,request.IsImmortal,
|
||||
request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor,
|
||||
request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity,
|
||||
request.UseCount, request.IsForInvitation,request.IsForFirstPurchase, request.IsSpecialOffer);
|
||||
newEnt.Id = ent.Id;
|
||||
newEnt.CreatedAt = ent.CreatedAt;
|
||||
newEnt.CreatedBy = ent.CreatedBy;
|
||||
|
@ -29,10 +34,12 @@ public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountComman
|
|||
if (catEnt == null)
|
||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var catDis = CategoryDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
||||
request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||
request.IsForInvitation,request.IsSpecialOffer, request.CategoryId);
|
||||
var catDis = CategoryDiscount.Create(request.Code, request.Description,
|
||||
request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal,
|
||||
request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor,
|
||||
request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity,
|
||||
request.UseCount, request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.CategoryId);
|
||||
catDis.Id = catEnt.Id;
|
||||
catDis.CreatedAt = catEnt.CreatedAt;
|
||||
catDis.CreatedBy = catEnt.CreatedBy;
|
||||
|
@ -44,10 +51,12 @@ public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountComman
|
|||
if (productEnt == null)
|
||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var productDis = ProductDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
||||
request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||
request.IsForInvitation, request.IsSpecialOffer, request.ProductId);
|
||||
var productDis = ProductDiscount.Create(request.Code, request.Description,
|
||||
request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||
request.AmountType, request.Type, request.Count, request.IsImmortal,
|
||||
request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor,
|
||||
request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity,
|
||||
request.UseCount, request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.ProductId);
|
||||
productDis.Id = productEnt.Id;
|
||||
productDis.CreatedAt = productEnt.CreatedAt;
|
||||
productDis.CreatedBy = productEnt.CreatedBy;
|
||||
|
|
1817
NetinaShop.Repository/Migrations/20240414120218_editDiscountAddFirstPurchase.Designer.cs
generated
100644
1817
NetinaShop.Repository/Migrations/20240414120218_editDiscountAddFirstPurchase.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -147,6 +147,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
|
@ -164,6 +165,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("OrderId")
|
||||
|
@ -173,6 +175,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Status")
|
||||
|
@ -214,6 +217,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsRemoved")
|
||||
|
@ -226,6 +230,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ReadingTime")
|
||||
|
@ -235,6 +240,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Summery")
|
||||
|
@ -266,6 +272,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
|
@ -279,6 +286,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
|
@ -289,6 +297,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -306,6 +315,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
|
@ -326,6 +336,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PageUrl")
|
||||
|
@ -340,6 +351,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -370,6 +382,11 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("DiscountAmount")
|
||||
|
@ -398,6 +415,9 @@ namespace NetinaShop.Repository.Migrations
|
|||
b.Property<bool>("Immortal")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsForFirstPurchase")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsForInvitation")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
|
@ -417,6 +437,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("PriceCeiling")
|
||||
|
@ -429,6 +450,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
|
@ -461,6 +483,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DeliveredAt")
|
||||
|
@ -499,6 +522,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("OrderAt")
|
||||
|
@ -526,6 +550,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("ServicePrice")
|
||||
|
@ -565,6 +590,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("DeliveryCost")
|
||||
|
@ -577,6 +603,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("OrderId")
|
||||
|
@ -586,6 +613,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ShippingId")
|
||||
|
@ -620,6 +648,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("HasDiscount")
|
||||
|
@ -632,6 +661,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("OrderId")
|
||||
|
@ -665,6 +695,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -686,6 +717,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
|
@ -702,6 +734,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
|
@ -715,6 +748,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -746,6 +780,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("EnglishName")
|
||||
|
@ -772,6 +807,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("PackingCost")
|
||||
|
@ -788,6 +824,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ReviewCount")
|
||||
|
@ -834,6 +871,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsBuyer")
|
||||
|
@ -849,6 +887,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
|
@ -861,6 +900,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Title")
|
||||
|
@ -889,6 +929,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Detail")
|
||||
|
@ -905,6 +946,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("ParentId")
|
||||
|
@ -917,6 +959,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Title")
|
||||
|
@ -946,6 +989,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Discriminator")
|
||||
|
@ -977,6 +1021,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
|
@ -987,6 +1032,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -1136,6 +1182,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
|
@ -1149,6 +1196,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
|
@ -1159,6 +1207,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -1188,6 +1237,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsRemoved")
|
||||
|
@ -1203,6 +1253,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Plaque")
|
||||
|
@ -1229,6 +1280,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
|
@ -1251,6 +1303,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsRemoved")
|
||||
|
@ -1260,6 +1313,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
|
@ -1269,6 +1323,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
|
@ -1293,6 +1348,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("CreatedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("DeliveryCost")
|
||||
|
@ -1314,6 +1370,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("ModifiedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
|
@ -1324,6 +1381,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("RemovedBy")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WarehouseName")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace NetinaShop.Repository.Models;
|
||||
|
||||
|
@ -15,7 +16,6 @@ public class ApplicationContext : IdentityDbContext<ApplicationUser, Application
|
|||
_projectAssembly = options.GetExtension<DbContextOptionCustomExtensions>().ProjectAssembly;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
|
@ -31,6 +31,7 @@ public class ApplicationContext : IdentityDbContext<ApplicationUser, Application
|
|||
builder.RegisterEntityTypeConfiguration(entitiesAssembly);
|
||||
builder.AddPluralizingTableNameConvention();
|
||||
builder.AddRestrictDeleteBehaviorConvention();
|
||||
|
||||
//builder.AddSequentialGuidForIdConvention();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ public class DbInitializerService : IDbInitializerService
|
|||
private readonly IOptionsSnapshot<SiteSettings> _adminUserSeedOptions;
|
||||
private readonly ApplicationContext _context;
|
||||
private readonly ILogger<DbInitializerService> _logger;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly RoleManager<ApplicationRole> _roleManager;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
|
||||
|
@ -16,13 +17,15 @@ public class DbInitializerService : IDbInitializerService
|
|||
RoleManager<ApplicationRole> roleManager,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IOptionsSnapshot<SiteSettings> adminUserSeedOptions,
|
||||
ILogger<DbInitializerService> logger)
|
||||
ILogger<DbInitializerService> logger,
|
||||
IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_context = context;
|
||||
_roleManager = roleManager;
|
||||
_userManager = userManager;
|
||||
_adminUserSeedOptions = adminUserSeedOptions;
|
||||
_logger = logger;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
@ -44,6 +47,7 @@ public class DbInitializerService : IDbInitializerService
|
|||
{
|
||||
await SeedRoles();
|
||||
var seedAdmin = _adminUserSeedOptions.Value.UserSetting;
|
||||
var manager = _adminUserSeedOptions.Value.Manager;
|
||||
var user = await _userManager.FindByNameAsync(seedAdmin.Username);
|
||||
if (user == null)
|
||||
{
|
||||
|
@ -61,26 +65,38 @@ public class DbInitializerService : IDbInitializerService
|
|||
BirthDate = DateTime.Now.AddYears(-23)
|
||||
};
|
||||
var adminUserResult = await _userManager.CreateAsync(adminUser, seedAdmin.Password);
|
||||
_repositoryWrapper.SetRepository<Manager>()
|
||||
.Add(new Manager
|
||||
{
|
||||
UserId = adminUser.Id
|
||||
});
|
||||
await _repositoryWrapper.SaveChangesAsync(default);
|
||||
if (adminUserResult.Succeeded) await _userManager.AddToRoleAsync(adminUser, seedAdmin.RoleName);
|
||||
}
|
||||
|
||||
var mahanUser = await _userManager.FindByNameAsync("09128387004");
|
||||
var mahanUser = await _userManager.FindByNameAsync(manager.Username);
|
||||
if (mahanUser == null)
|
||||
{
|
||||
mahanUser = new ApplicationUser
|
||||
{
|
||||
UserName = "09128387004",
|
||||
Email = "mahanmasiha6@gmail.com",
|
||||
UserName = manager.Username,
|
||||
Email = manager.Email,
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = true,
|
||||
FirstName = "ماهان",
|
||||
LastName = "",
|
||||
FirstName = manager.FirstName,
|
||||
LastName = manager.LastName,
|
||||
Gender = Gender.Male,
|
||||
PhoneNumberConfirmed = true,
|
||||
PhoneNumber = "09128387004",
|
||||
PhoneNumber = manager.Phone,
|
||||
BirthDate = DateTime.Now.AddYears(-23)
|
||||
};
|
||||
var adminUserResult = await _userManager.CreateAsync(mahanUser, seedAdmin.Password);
|
||||
_repositoryWrapper.SetRepository<Manager>()
|
||||
.Add(new Manager
|
||||
{
|
||||
UserId = mahanUser.Id
|
||||
});
|
||||
await _repositoryWrapper.SaveChangesAsync(default);
|
||||
if (adminUserResult.Succeeded) await _userManager.AddToRoleAsync(mahanUser, "Manager");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue