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(IDevicePartsStorageLocationsService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsStorageLocationsService : BaseService, IDevicePartsStorageLocationsService
{
///
/// 查询备品备件库位列表
///
///
///
public PagedInfo GetList(DevicePartsStorageLocationsQueryDto parm)
{
var predicate = Expressionable.Create();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
public string[] QueryDevicePartsStorageLocationsLocationCode(string query)
{
return Queryable()
.WhereIF(!string.IsNullOrEmpty(query),x => x.LocationCode.Contains(query))
.Select(x => x.LocationCode)
.ToArray();
}
///
/// 获取详情
///
///
///
public DevicePartsStorageLocations GetInfo(int LocationId)
{
var response = Queryable()
.Where(x => x.LocationId == LocationId)
.First();
return response;
}
///
/// 添加备品备件库位
///
///
///
public DevicePartsStorageLocations AddDevicePartsStorageLocations(DevicePartsStorageLocations model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改备品备件库位
///
///
///
public int UpdateDevicePartsStorageLocations(DevicePartsStorageLocations model)
{
//var response = Update(w => w.LocationId == model.LocationId, it => new DevicePartsStorageLocations()
//{
// LocationCode = model.LocationCode,
// Description = model.Description,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}