You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.7 KiB
C#

using DS.Module.SqlSugar;
namespace Ds.WMS.Finance.MediatR.handlers
{
/// <summary>
/// 具体的业务逻辑
/// </summary>
public class GetCostBasicHandler : IRequestHandler<CostExchangeRateCommand, CurrencyDto>
{
private readonly DsDataAppService<Code_Currency> _db;
/// <summary>
///
/// </summary>
/// <param name="db"></param>
public GetCostBasicHandler(DsDataAppService<Code_Currency> db)
{
_db = db;
}
/// <summary>
/// 具体的业务逻辑
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
async Task<CurrencyDto> IRequestHandler<CostExchangeRateCommand, CurrencyDto>.Handle(CostExchangeRateCommand request, CancellationToken cancellationToken)
{
var list = await _db.QueryForOneEntity<CurrencyDto>(x => x.Id == request.Id);
11 months ago
return await Task.FromResult(list);
}
}
11 months ago
/// <summary>
/// 添加
/// </summary>
public class AddCostBasicHandler : IRequestHandler<CostExchangeForAddCommand, bool>
{
private readonly DsDataAppService<Code_Currency> _db;
/// <summary>
///
/// </summary>
/// <param name="db"></param>
public AddCostBasicHandler(DsDataAppService<Code_Currency> db)
11 months ago
{
_db = db;
}
11 months ago
public async Task<bool> Handle(CostExchangeForAddCommand request, CancellationToken cancellationToken)
{
var list = await _db.InsertForTran(new Code_Currency()
11 months ago
{
CodeName = request.CodeName,
DefaultRate = request.DefaultRate,
Description = request.Description,
FinanceSoftCodes = request.FinanceSoftCodes,
Name = request.Name
});
11 months ago
return await Task.FromResult(list);
}
}
11 months ago
/// <summary>
/// 删除
/// </summary>
public class DelCostBasicHandler : IRequestHandler<CostExchangeForDelCommand, bool>
{
private readonly ISqlSugarClient _db;
11 months ago
public DelCostBasicHandler(ISqlSugarClient db)
{
_db = db;
}
11 months ago
public async Task<bool> Handle(CostExchangeForDelCommand request, CancellationToken cancellationToken)
{
var list = await _db.Updateable<Code_Currency>()
.Where(p => p.Id.Equals(request.Id))
.IgnoreColumns(true)
.SetColumns(p => p.DsIsDel == true)
.ExecuteCommandAsync() > 0;
return await Task.FromResult(list);
}
}
}