using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
namespace DS.WMS.Core.Code.Method
{
public class CodeInvoiceService : ServiceBase, ICodeInvoiceService
{
///
/// 初始化
///
///
public CodeInvoiceService(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
///
/// 列表
///
///
///
public async Task>> GetListAsync(PageRequest request)
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable()
.Where(whereList)
.ToQueryPage(request.PageCondition);
return data;
}
///
/// 获取详情
///
///
///
public async Task> GetAsync(long id)
{
var ci = await TenantDb.Queryable().FirstAsync(x => x.Id == id);
return DataResult.Success(ci);
}
///
/// 新增/修改
///
///
///
public async Task> EditAsync(CodeInvoice ci)
{
try
{
await TenantDb.Storageable(ci).DefaultAddElseUpdate().ExecuteCommandAsync();
return DataResult.Success(ci);
}
catch (Exception ex)
{
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
///
/// 删除
///
///
///
public async Task DeleteAsync(params long[] ids)
{
int rows = await TenantDb.Deleteable().Where(x => ids.Contains(x.Id)).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
}