using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Model.MES.dev.Dto;
using DOAN.Model.MES.dev;
using DOAN.Repository;
using DOAN.Service.MES.dev.IService;
using System.Linq;
namespace DOAN.Service.MES.dev
{
///
/// 备品备件出入库Service业务层处理
///
[AppService(ServiceType = typeof(IDevicePartsTransactionsService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsTransactionsService : BaseService, IDevicePartsTransactionsService
{
///
/// 查询备品备件出入库列表
///
///
///
public PagedInfo GetList(DevicePartsTransactionsQueryDto parm)
{
// var predicate = Expressionable.Create();
var response = Queryable()
.LeftJoin((t,s)=>t.PartId==s.PartId)
.WhereIF(!string.IsNullOrEmpty(parm.PartName), (t,s)=>s.PartName.Contains(parm.PartName))
.WhereIF(!string.IsNullOrEmpty(parm.TransactionType), (t,s)=>t.TransactionType==parm.TransactionType)
.Select((t,s)=>new DevicePartsTransactionsDto(),true )
.ToPage_NO_Convert(parm);
return response;
}
///
/// 获取详情
///
///
///
public DevicePartsTransactions GetInfo(int TransactionId)
{
var response = Queryable()
.Where(x => x.TransactionId == TransactionId)
.First();
return response;
}
///
/// 添加备品备件出入库
///
///
///
public DevicePartsTransactions AddDevicePartsTransactions(DevicePartsTransactions model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改备品备件出入库
///
///
///
public int UpdateDevicePartsTransactions(DevicePartsTransactions model)
{
//var response = Update(w => w.TransactionId == model.TransactionId, it => new DevicePartsTransactions()
//{
// TransactionType = model.TransactionType,
// Quantity = model.Quantity,
// TransactionDate = model.TransactionDate,
// Remarks = model.Remarks,
// CreatedBy = model.CreatedBy,
//});
//return response;
return Update(model, true);
}
}
}