public PaiBan UpdateSingle(int id, PaiBanReq data) { PaiBan model = db.PaiBan.Find(id); SetPaiBan(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public PaiBan SetPaiBan(PaiBan model, PaiBanReq data) { if (data.OptId != null) { model.OptId = data.OptId.Value; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.CreateDate != null && data.CreateDate != DateTime.MinValue && data.CreateDate != SqlDateTime.MinValue.Value) { model.CreateDate = data.CreateDate.Value; } if (data.EmployeeId != null) { model.EmployeeId = data.EmployeeId.Value; } if (!string.IsNullOrEmpty(data.EmployeeName)) { model.EmployeeName = data.EmployeeName; } if (!string.IsNullOrEmpty(data.BanType)) { model.BanType = data.BanType; } if (data.BanHours != null) { model.BanHours = data.BanHours.Value; } if (data.ServerDate != null && data.ServerDate != DateTime.MinValue && data.ServerDate != SqlDateTime.MinValue.Value) { model.ServerDate = data.ServerDate.Value; } if (data.AddHours != null) { model.AddHours = data.AddHours.Value; } // if (!string.IsNullOrEmpty(data.DayType)) model.DayType = data.DayType; if (data.projectid != null) { model.projectid = data.projectid.Value; } if (!string.IsNullOrEmpty(data.ProjectName)) { model.ProjectName = data.ProjectName; } if (data.BanTypeId != null) { model.BanTypeId = data.BanTypeId.Value; } if (data.WashHead != null) { model.WashHead = data.WashHead.Value; } if (data.WashBody != null) { model.WashBody = data.WashBody.Value; } if (data.KaiNai != null) { model.KaiNai = data.KaiNai.Value; } // if (!string.IsNullOrEmpty(data.KaiNaiFree)) model.KaiNaiFree = data.KaiNaiFree; //if (!string.IsNullOrEmpty(data.KuangGong)) model.KuangGong = data.KuangGong; if (data.ChiDao != null) { model.ChiDao = data.ChiDao.Value; } //if (!string.IsNullOrEmpty(data.QueKa)) model.QueKa = data.QueKa; if (data.JiangLi != null) { model.JiangLi = data.JiangLi.Value; } //if (!string.IsNullOrEmpty(data.Mark)) model.Mark = data.Mark; if (data.HolidayHours != null) { model.HolidayHours = data.HolidayHours; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (null != data.QinJiaHours) { model.QinJiaHours = data.QinJiaHours; } if (!string.IsNullOrEmpty(data.QinJiaType)) { model.QinJiaType = data.QinJiaType; } return(model); }