diff --git a/Mango.Nop.Core/Dtos/CustomerDto.cs b/Mango.Nop.Core/Dtos/CustomerDto.cs new file mode 100644 index 0000000..95ac8ab --- /dev/null +++ b/Mango.Nop.Core/Dtos/CustomerDto.cs @@ -0,0 +1,47 @@ +using Nop.Core.Domain.Common; +using Nop.Core.Domain.Customers; + +namespace Mango.Nop.Core.Dtos; + +public class CustomerDto : ModelDtoBase, ISoftDeletedEntity +{ + public string Username { get; set; } + public string Email { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + + public bool Deleted { get; set; } + + public CustomerDto() :base() + { } + public CustomerDto(int customerId) : base(customerId) + { } + + public CustomerDto(Customer customer) : base(customer) + { + } + + public override void CopyDtoValuesToEntity(Customer entity) + { + base.CopyDtoValuesToEntity(entity); + + entity.Username = Username; + entity.FirstName = FirstName; + entity.LastName = LastName; + entity.Email = Email; + + entity.Deleted = Deleted; + } + + public override void CopyEntityValuesToDto(Customer entity) + { + base.CopyEntityValuesToDto(entity); + + Username = entity.Username; + FirstName = entity.FirstName; + LastName = entity.LastName; + Email = entity.Email; + + Deleted = entity.Deleted; + } +} \ No newline at end of file diff --git a/Mango.Nop.Core/Dtos/IModelDtoBase.cs b/Mango.Nop.Core/Dtos/IModelDtoBase.cs new file mode 100644 index 0000000..3d4fa08 --- /dev/null +++ b/Mango.Nop.Core/Dtos/IModelDtoBase.cs @@ -0,0 +1,18 @@ +using AyCode.Interfaces; +using AyCode.Interfaces.Entities; +using Nop.Core; + +namespace Mango.Nop.Core.Dtos; + +public interface IModelDtoBaseEmpty : IAcModelDtoBaseEmpty +{ +} + +public interface IModelDtoBase : IEntityInt, IModelDtoBaseEmpty +{ +} + +public interface IModelDtoBase : IModelDtoBase where TMainEntity : BaseEntity +{ + TMainEntity CreateMainEntity(); +} \ No newline at end of file diff --git a/Mango.Nop.Core/Dtos/ModelDtoBase.cs b/Mango.Nop.Core/Dtos/ModelDtoBase.cs new file mode 100644 index 0000000..b6ac8a8 --- /dev/null +++ b/Mango.Nop.Core/Dtos/ModelDtoBase.cs @@ -0,0 +1,45 @@ +using Nop.Core; + +namespace Mango.Nop.Core.Dtos; + +public abstract class ModelDtoBase : IModelDtoBase +{ + public int Id { get; set; } + + protected ModelDtoBase(){} + protected ModelDtoBase(int id) => Id = id; +} + +public abstract class ModelDtoBase : ModelDtoBase, IModelDtoBase where TMainEntity : BaseEntity +{ + protected ModelDtoBase() : base() + { + } + + protected ModelDtoBase(int id) : base(id) + { + } + + protected ModelDtoBase(TMainEntity mainEntity) + { + CopyEntityValuesToDto(mainEntity); + } + + public virtual TMainEntity CreateMainEntity() + { + var mainEntity = Activator.CreateInstance(); + CopyDtoValuesToEntity(mainEntity); + + return mainEntity; + } + + public virtual void CopyDtoValuesToEntity(TMainEntity entity) + { + entity.Id = Id; + } + + public virtual void CopyEntityValuesToDto(TMainEntity entity) + { + Id = entity.Id; + } +} \ No newline at end of file diff --git a/Mango.Nop.Core/Dtos/ProductDto.cs b/Mango.Nop.Core/Dtos/ProductDto.cs new file mode 100644 index 0000000..6606c2d --- /dev/null +++ b/Mango.Nop.Core/Dtos/ProductDto.cs @@ -0,0 +1,75 @@ +using Nop.Core.Domain.Catalog; +using Nop.Core.Domain.Common; + +namespace Mango.Nop.Core.Dtos; + +public class ProductDto : ModelDtoBase, ISoftDeletedEntity +{ + public int ProductTypeId { get; set; } + public int ParentGroupedProductId { get; set; } + + public string Name { get; set; } + public string ShortDescription { get; set; } + public string FullDescription { get; set; } + + public int WarehouseId { get; set; } + public int StockQuantity { get; set; } + + public decimal Weight { get; set; } + public decimal Length { get; set; } + public decimal Width { get; set; } + public decimal Height { get; set; } + + public bool Deleted { get; set; } + + public ProductDto() :base() + { } + public ProductDto(int product) : base(product) + { } + public ProductDto(Product product) : base(product) + { } + + public override void CopyDtoValuesToEntity(Product entity) + { + base.CopyDtoValuesToEntity(entity); + + entity.ProductTypeId = ProductTypeId; + entity.ParentGroupedProductId = ParentGroupedProductId; + + entity.Name = Name; + entity.ShortDescription = ShortDescription; + entity.FullDescription = FullDescription; + + entity.WarehouseId = WarehouseId; + entity.StockQuantity = StockQuantity; + + entity.Weight = Weight; + entity.Length = Length; + entity.Width = Width; + entity.Height = Height; + + entity.Deleted = Deleted; + } + + public override void CopyEntityValuesToDto(Product entity) + { + base.CopyEntityValuesToDto(entity); + + ProductTypeId = entity.ProductTypeId; + ParentGroupedProductId = entity.ParentGroupedProductId; + + Name = entity.Name; + ShortDescription = entity.ShortDescription; + FullDescription = entity.FullDescription; + + WarehouseId = entity.WarehouseId; + StockQuantity = entity.StockQuantity; + + Weight = entity.Weight; + Length = entity.Length; + Width = entity.Width; + Height = entity.Height; + + Deleted = entity.Deleted; + } +} \ No newline at end of file diff --git a/Mango.Nop.Core/Models/MgLoginModelRequest.cs b/Mango.Nop.Core/Models/MgLoginModelRequest.cs new file mode 100644 index 0000000..09d48df --- /dev/null +++ b/Mango.Nop.Core/Models/MgLoginModelRequest.cs @@ -0,0 +1,10 @@ +using AyCode.Interfaces; +using Mango.Nop.Core.Interfaces; + +namespace Mango.Nop.Core.Models; + +public class MgLoginModelRequest(string email, string password) : IAcModelDtoBaseEmpty +{ + public string Email { get; set; } = email; + public string Password { get; set; } = password; +} \ No newline at end of file diff --git a/Mango.Nop.Core/Models/MgLoginModelResponse.cs b/Mango.Nop.Core/Models/MgLoginModelResponse.cs new file mode 100644 index 0000000..2511b1c --- /dev/null +++ b/Mango.Nop.Core/Models/MgLoginModelResponse.cs @@ -0,0 +1,21 @@ +using AyCode.Interfaces; +using Mango.Nop.Core.Dtos; +using Nop.Core.Domain.Customers; + +namespace Mango.Nop.Core.Models; + +public class MgLoginModelResponse : IAcModelDtoBaseEmpty +{ + public CustomerDto CustomerDto { get; set; } + public string ErrorMessage { get; set; } + + public MgLoginModelResponse() + { } + public MgLoginModelResponse(Customer customer, string errorMessage) : this(new CustomerDto(customer), errorMessage) + { } + public MgLoginModelResponse(CustomerDto customerDto, string errorMessage) + { + CustomerDto = customerDto; + ErrorMessage = errorMessage; + } +} \ No newline at end of file diff --git a/Mango.Nop.Core/Repositories/MgDbTableBase.cs b/Mango.Nop.Core/Repositories/MgDbTableBase.cs index aa4405c..24dc6fe 100644 --- a/Mango.Nop.Core/Repositories/MgDbTableBase.cs +++ b/Mango.Nop.Core/Repositories/MgDbTableBase.cs @@ -20,6 +20,8 @@ public class MgDbTableBase(IEventPublisher eventPublisher, INopDataProv protected INopDataProvider DataProvider = dataProvider; protected IShortTermCacheManager ShortTermCacheManager = shortTermCacheManager; + public IQueryable GetAll() => Table; + #region SetTimeStampInfos private static void SetTimeStampCreated(TEntity entity) {