Compare commits

...

3 Commits

Author SHA1 Message Date
Loretta 5e2c30a4ec improvement, fixes, etc... 2025-09-12 13:34:54 +02:00
Loretta ef16260ebe improvements, fixes, etc... 2025-09-11 12:51:58 +02:00
Loretta 60f0071ade NopLogWriter fixes; SignalRLogger fixes; etc... 2025-09-05 06:18:01 +02:00
8 changed files with 277 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Core.Enums;
using AyCode.Entities;
using AyCode.Entities.Server.LogItems;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Org.BouncyCastle.Utilities.IO;
using Nop.Core.Domain.Logging;
using Nop.Services.Logging;
using LogLevel = AyCode.Core.Loggers.LogLevel;
namespace Mango.Nop.Core.Loggers
{
public class NopLogWriter : AcLogItemWriterBase<AcLogItem>//AcTextLogWriterBase
{
private readonly ILogger _nopLogger;
public NopLogWriter(ILogger nopLogger) : this(nopLogger, null)
{ }
public NopLogWriter(ILogger nopLogger, string? categoryName = null) : base(categoryName)
{
_nopLogger = nopLogger;
}
//public NopLogWriter(ILogger nopLogger, AppType appType, LogLevel logLevel, string? categoryName = null) : base(appType, logLevel, categoryName)
//{
// _nopLogger=nopLogger;
//}
protected override void WriteLogItemCallback(AcLogItem logItem)
{
switch (logItem.LogLevel)
{
case LogLevel.Detail:
case LogLevel.Trace:
case LogLevel.Debug:
case LogLevel.Info:
_nopLogger.Information(logItem.Text);
break;
case LogLevel.Suggest:
case LogLevel.Warning:
_nopLogger.Warning(logItem.Text);
break;
case LogLevel.Error:
_nopLogger.Error(logItem.Text);//, logItem.Exception);
break;
case LogLevel.Disabled:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -20,6 +20,8 @@ public class MgDbTableBase<TEntity>(IEventPublisher eventPublisher, INopDataProv
protected INopDataProvider DataProvider = dataProvider;
protected IShortTermCacheManager ShortTermCacheManager = shortTermCacheManager;
public virtual IQueryable<TEntity> GetAll() => Table;
#region SetTimeStampInfos
private static void SetTimeStampCreated(TEntity entity)
{