StockQuantityHistoryExt, StockQuantityHistoryDto; improvements, fixes;

This commit is contained in:
Loretta 2025-11-13 19:58:39 +01:00
parent 7946a52219
commit 82c3b5a7cd
3 changed files with 127 additions and 1 deletions

View File

@ -0,0 +1,70 @@
using AyCode.Interfaces.Entities;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Interfaces;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Common;
using Nop.Core.Domain.Orders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mango.Nop.Core.Dtos
{
public interface IMgTStockQuantityHistoryDto<TProductDto> : IEntityInt, IMgStockQuantityHistory where TProductDto : IMgProductDto
{
public TProductDto ProductDto { get; set; }
}
public abstract class MgStockQuantityHistoryDto<TProductDto> : MgEntityBase, IModelDtoBase<StockQuantityHistory>,
IMgTStockQuantityHistoryDto<TProductDto> where TProductDto : IMgProductDto
{
public int ProductId { get; set; }
public int QuantityAdjustment { get; set; }
public int StockQuantity { get; set; }
public string Message { get; set; }
public int? CombinationId { get; set; }
public int? WarehouseId { get; set; }
public DateTime CreatedOnUtc { get; set; }
[Association(ThisKey = nameof(ProductId), OtherKey = nameof(IMgProductDto.Id), CanBeNull = false)]
public TProductDto ProductDto { get; set; }
public void CopyDtoValuesToEntity(Order entity)
{
throw new NotImplementedException();
}
public void CopyDtoValuesToEntity(StockQuantityHistory entity)
{
throw new NotImplementedException();
}
public void CopyEntityValuesToDto(Order entity)
{
throw new NotImplementedException();
}
public void CopyEntityValuesToDto(StockQuantityHistory entity)
{
throw new NotImplementedException();
}
public Order CreateMainEntity()
{
throw new NotImplementedException();
}
StockQuantityHistory IModelDtoBase<StockQuantityHistory>.CreateMainEntity()
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,56 @@
using AyCode.Interfaces.Entities;
using Mango.Nop.Core.Interfaces;
namespace Nop.Core.Domain.Catalog;
public interface IMgStockQuantityHistory
{
public int ProductId { get; set; }
public int QuantityAdjustment { get; set; }
public int StockQuantity { get; set; }
public string Message { get; set; }
public int? CombinationId { get; set; }
public int? WarehouseId { get; set; }
public DateTime CreatedOnUtc { get; set; }
}
/// <summary>
/// Represents a stock quantity change entry
/// </summary>
public partial class StockQuantityHistory : BaseEntity, IMgStockQuantityHistory
{
/// <summary>
/// Gets or sets the stock quantity adjustment
/// </summary>
public int QuantityAdjustment { get; set; }
/// <summary>
/// Gets or sets current stock quantity
/// </summary>
public int StockQuantity { get; set; }
/// <summary>
/// Gets or sets the message
/// </summary>
public string Message { get; set; }
/// <summary>
/// Gets or sets the date and time of instance creation
/// </summary>
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the product identifier
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// Gets or sets the product attribute combination identifier
/// </summary>
public int? CombinationId { get; set; }
/// <summary>
/// Gets or sets the warehouse identifier
/// </summary>
public int? WarehouseId { get; set; }
}

View File

@ -21,7 +21,7 @@ public abstract class MgDtoDbTableBase<TDtoEntity, TMainEntity> : MgDbTableBase<
public async Task<TMainEntity?> GetMainEntityById(int id) => await _dataProvider.GetTable<TMainEntity>().FirstOrDefaultAsync(x => x.Id == id);
public async Task<int> DeleteMainEntityById(int id, bool publishEvent = true)
public virtual async Task<int> DeleteMainEntityById(int id, bool publishEvent = true)
{
var affectedRows = 0;