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