/// <summary> /// 设置可用,设置停用 /// </summary> /// <param name="ids"></param> /// <param name="state"></param> /// <returns></returns> public OpResult SetState(string ids, short state) { var sId = ids.Split(',').Select(o => int.Parse(o)); var olist = DevicesRepository.GetQuery(o => sId.Contains(o.Id)).ToList(); olist.Each(o => o.Status = state); return(OpResult.Result(DevicesRepository.SaveChanges())); }
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()); }