public YiHaoPing UpdateSingle(int id, YiHaoPingReq data) { YiHaoPing model = db.YiHaoPing.Find(id); SetYiHaoPing(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public YiHaoPing SetYiHaoPing(YiHaoPing model, YiHaoPingReq data) { if (data.HPId != null) { model.HPId = data.HPId.Value; } if (!string.IsNullOrEmpty(data.HPName)) { model.HPName = data.HPName; } if (data.shenqingNum != null) { model.shenqingNum = data.shenqingNum.Value; } if (data.projectid != null) { model.projectid = data.projectid.Value; } if (!string.IsNullOrEmpty(data.shenqingRen)) { model.shenqingRen = data.shenqingRen; } if (!string.IsNullOrEmpty(data.shenpiRen)) { model.shenpiRen = data.shenpiRen; } if (!string.IsNullOrEmpty(data.lingliaoRen)) { model.lingliaoRen = data.lingliaoRen; } if (data.shenqingDate != null && data.shenqingDate != DateTime.MinValue && data.shenqingDate != SqlDateTime.MinValue.Value) { model.shenqingDate = data.shenqingDate.Value; } if (data.shenPiDate != null && data.shenPiDate != DateTime.MinValue && data.shenPiDate != SqlDateTime.MinValue.Value) { model.shenPiDate = data.shenPiDate.Value; } if (data.lingliaoDate != null && data.lingliaoDate != DateTime.MinValue && data.lingliaoDate != SqlDateTime.MinValue.Value) { model.lingliaoDate = data.lingliaoDate.Value; } if (data.lingliaoRenId != null) { model.lingliaoRenId = data.lingliaoRenId.Value; } if (data.shenpiRenId != null) { model.shenpiRenId = data.shenpiRenId.Value; } if (data.shenqingRenId != null) { model.shenqingRenId = data.shenqingRenId.Value; } if (!string.IsNullOrEmpty(data.projectName)) { model.projectName = data.projectName; } if (!string.IsNullOrEmpty(data.Mark)) { model.Mark = data.Mark; } return(model); }