public DietDayNote UpdateSingle(int id, DietDayNoteReq data) { DietDayNote model = db.DietDayNote.Find(id); SetDietDayNote(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public DietDayNote SetDietDayNote(DietDayNote model, DietDayNoteReq data) { if (data.ServerDate != null && data.ServerDate != DateTime.MinValue && data.ServerDate != SqlDateTime.MinValue.Value) { model.ServerDate = data.ServerDate.Value; } if (data.LunchEmployeeCount != null) { model.LunchEmployeeCount = data.LunchEmployeeCount.Value; } if (data.SupperEmployeeCount != null) { model.SupperEmployeeCount = data.SupperEmployeeCount.Value; } if (!string.IsNullOrEmpty(data.LunchNote)) { model.LunchNote = data.LunchNote; } if (!string.IsNullOrEmpty(data.SupperNote)) { model.SupperNote = data.SupperNote; } if (!string.IsNullOrEmpty(data.OtherNote)) { model.OtherNote = data.OtherNote; } if (data.CreateDate != null && data.CreateDate != DateTime.MinValue && data.CreateDate != SqlDateTime.MinValue.Value) { model.CreateDate = data.CreateDate.Value; } if (data.OptId != null) { model.OptId = data.OptId.Value; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.projectid != null) { model.projectid = data.projectid.Value; } return(model); }