improvements, fixes, etc...
This commit is contained in:
parent
60f0071ade
commit
ef16260ebe
|
|
@ -0,0 +1,47 @@
|
|||
using Nop.Core.Domain.Common;
|
||||
using Nop.Core.Domain.Customers;
|
||||
|
||||
namespace Mango.Nop.Core.Dtos;
|
||||
|
||||
public class CustomerDto : ModelDtoBase<Customer>, 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<out TMainEntity> : IModelDtoBase where TMainEntity : BaseEntity
|
||||
{
|
||||
TMainEntity CreateMainEntity();
|
||||
}
|
||||
|
|
@ -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<TMainEntity> : ModelDtoBase, IModelDtoBase<TMainEntity> 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<TMainEntity>();
|
||||
CopyDtoValuesToEntity(mainEntity);
|
||||
|
||||
return mainEntity;
|
||||
}
|
||||
|
||||
public virtual void CopyDtoValuesToEntity(TMainEntity entity)
|
||||
{
|
||||
entity.Id = Id;
|
||||
}
|
||||
|
||||
public virtual void CopyEntityValuesToDto(TMainEntity entity)
|
||||
{
|
||||
Id = entity.Id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
|
||||
namespace Mango.Nop.Core.Dtos;
|
||||
|
||||
public class ProductDto : ModelDtoBase<Product>, 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@ public class MgDbTableBase<TEntity>(IEventPublisher eventPublisher, INopDataProv
|
|||
protected INopDataProvider DataProvider = dataProvider;
|
||||
protected IShortTermCacheManager ShortTermCacheManager = shortTermCacheManager;
|
||||
|
||||
public IQueryable<TEntity> GetAll() => Table;
|
||||
|
||||
#region SetTimeStampInfos
|
||||
private static void SetTimeStampCreated(TEntity entity)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue