public Utility.OpResult SaveOrUpdate(Devices model) { IQueryable <Devices> isExist = null; if (model.Id == 0) { isExist = DevicesRepository.GetQuery(o => o.CategoryId == model.CategoryId && o.Title == model.Title && o.Brand == model.Brand && o.Spec == model.Spec); } else { isExist = DevicesRepository.GetQuery(o => o.CategoryId == model.CategoryId && o.Title == model.Title && o.Brand == model.Brand && o.Spec == model.Spec && o.Id != model.Id); } if (isExist.Any()) { return(OpResult.Fail("该条设备记录已经存在")); } if (model.Id == 0) { DevicesRepository.Add(model); } else { var source = DevicesRepository.Get(model.Id); model.ToCopyProperty(source, new List <string>() { "DeviceId", "Status", "CreateUID" }); } if (DevicesRepository.SaveChanges()) { LogEngine.WriteUpdate(model.Id + "," + model.Title, LogModule.设备管理); } return(OpResult.Success()); }
public Devices GetOne(object id) { return(DevicesRepository.Get(id)); }