zhuangpei-mesbackend/DOAN.Service/MES/dev/DevicePartsInventoryService.cs
2024-12-30 11:31:40 +08:00

82 lines
2.5 KiB
C#

using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Repository;
using DOAN.Model.MES.dev.Dto;
using DOAN.Model.MES.dev;
using System.Linq;
using DOAN.Service.MES.dev.IService;
namespace DOAN.Service.MES.dev
{
/// <summary>
/// 库存信息表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDevicePartsInventoryService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsInventoryService : BaseService<DevicePartsInventory>, IDevicePartsInventoryService
{
/// <summary>
/// 查询库存信息表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DevicePartsInventoryDto> GetList(DevicePartsInventoryQueryDto parm)
{
var predicate = Expressionable.Create<DevicePartsInventory>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<DevicePartsInventory, DevicePartsInventoryDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="InventoryId"></param>
/// <returns></returns>
public DevicePartsInventory GetInfo(int InventoryId)
{
var response = Queryable()
.Where(x => x.InventoryId == InventoryId)
.First();
return response;
}
/// <summary>
/// 添加库存信息表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DevicePartsInventory AddDevicePartsInventory(DevicePartsInventory model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改库存信息表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDevicePartsInventory(DevicePartsInventory model)
{
//var response = Update(w => w.InventoryId == model.InventoryId, it => new DevicePartsInventory()
//{
// Quantity = model.Quantity,
// Location = model.Location,
// LastInventoryCheck = model.LastInventoryCheck,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}