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 { /// /// 备品备件分类Service业务层处理 /// [AppService(ServiceType = typeof(IDevicePartsCategoriesService), ServiceLifetime = LifeTime.Transient)] public class DevicePartsCategoriesService : BaseService, IDevicePartsCategoriesService { /// /// 查询备品备件分类列表 /// /// /// public PagedInfo GetList(DevicePartsCategoriesQueryDto parm) { var predicate = Expressionable.Create() .AndIF(!string.IsNullOrEmpty(parm.CategoryName),it=>it.CategoryName.Contains(parm.CategoryName)) ; var response = Queryable() .Where(predicate.ToExpression()) .ToPage(parm); return response; } /// /// 获取详情 /// /// /// public DevicePartsCategories GetInfo(int CategoryId) { var response = Queryable() .Where(x => x.CategoryId == CategoryId) .First(); return response; } /// /// 添加备品备件分类 /// /// /// public DevicePartsCategories AddDevicePartsCategories(DevicePartsCategories model) { return Context.Insertable(model).ExecuteReturnEntity(); } /// /// 修改备品备件分类 /// /// /// public int UpdateDevicePartsCategories(DevicePartsCategories model) { //var response = Update(w => w.CategoryId == model.CategoryId, it => new DevicePartsCategories() //{ // CategoryName = model.CategoryName, // CreatedAt = model.CreatedAt, // UpdatedAt = model.UpdatedAt, //}); //return response; return Update(model, true); } } }