public HuoPingOut UpdateSingle(int id, HuoPingOutReq data) { HuoPingOut model = db.HuoPingOut.Find(id); SetHuoPingOut(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public HuoPingOut SetHuoPingOut(HuoPingOut model, HuoPingOutReq data) { if (data.HuoPingId != null) { model.HuoPingId = data.HuoPingId.Value; } if (!string.IsNullOrEmpty(data.HuoPingName)) { model.HuoPingName = data.HuoPingName; } if (data.Stock != null) { model.Stock = data.Stock.Value; } if (data.projectid != null) { model.projectid = data.projectid.Value; } if (!string.IsNullOrEmpty(data.ProjectName)) { model.ProjectName = data.ProjectName; } if (data.OptId != null) { model.OptId = data.OptId.Value; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.MonthNeed != null) { model.MonthNeed = data.MonthNeed.Value; } if (data.WeekOne != null) { model.WeekOne = data.WeekOne.Value; } if (data.WeekTwo != null) { model.WeekTwo = data.WeekTwo.Value; } if (data.WeekThree != null) { model.WeekThree = data.WeekThree.Value; } if (data.WeekFour != null) { model.WeekFour = data.WeekFour.Value; } if (data.WeekFive != null) { model.WeekFive = data.WeekFive.Value; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (!string.IsNullOrEmpty(data.Mark)) { model.Mark = data.Mark; } if (!string.IsNullOrEmpty(data.ServerMonth)) { model.ServerMonth = data.ServerMonth; } return(model); }