using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Repository;
using ZR.Service.Business.IBusinessService;
using System.Linq;
using ZR.Service.MES.dev.IService;
using ZR.Model.MES.dev;
namespace ZR.Service.MES.dev
{
///
/// 设备检查项Service业务层处理
///
[AppService(ServiceType = typeof(IDeviceInspectService), ServiceLifetime = LifeTime.Transient)]
public class DeviceInspectService : BaseService, IDeviceInspectService
{
///
/// 查询设备检查项列表
///
///
///
public PagedInfo GetList(DeviceInspectQueryDto parm)
{
var predicate = Expressionable.Create();
predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
.AndIF(parm.Status >= 0, it => it.Status == parm.Status);
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public DeviceInspect GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加设备检查项
///
///
///
public DeviceInspect AddDeviceInspect(DeviceInspect model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改设备检查项
///
///
///
public int UpdateDeviceInspect(DeviceInspect model)
{
//var response = Update(w => w.Id == model.Id, it => new DeviceInspect()
//{
// Image = model.Image,
// Sort = model.Sort,
// Type = model.Type,
// Remark = model.Remark,
// Status = model.Status,
// Name = model.Name,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}