public MenDianFee UpdateSingle(int id, MenDianFeeReq data) { MenDianFee model = db.MenDianFee.Find(id); SetMenDianFee(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="model"></param> /// <param name="data"></param> /// <returns></returns> public MenDianFee SetMenDianFee(MenDianFee model, MenDianFeeReq data) { if (data.feiYongMoney != null) { model.feiYongMoney = data.feiYongMoney.Value; } if (!string.IsNullOrEmpty(data.info)) { model.info = data.info; } if (data.payDate != null && data.payDate != DateTime.MinValue && data.payDate != SqlDateTime.MinValue.Value) { model.payDate = data.payDate.Value; } if (!string.IsNullOrEmpty(data.optName)) { model.optName = data.optName; } if (data.optId != null) { model.optId = data.optId.Value; } if (data.createdate != null && data.createdate != DateTime.MinValue && data.createdate != SqlDateTime.MinValue.Value) { model.createdate = data.createdate.Value; } if (!string.IsNullOrEmpty(data.checkName)) { model.checkName = data.checkName; } if (data.checkId != null) { model.checkId = data.checkId.Value; } if (data.checkDate != null && data.checkDate != DateTime.MinValue && data.checkDate != SqlDateTime.MinValue.Value) { model.checkDate = data.checkDate.Value; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (data.projectid != null) { model.projectid = data.projectid.Value; } if (!string.IsNullOrEmpty(data.projectName)) { model.projectName = data.projectName; } if (!string.IsNullOrEmpty(data.category)) { model.category = data.category; } if (!string.IsNullOrEmpty(data.fkFangShi)) { model.fkFangShi = data.fkFangShi; } if (data.JiaoGeId != null) { model.JiaoGeId = data.JiaoGeId.Value; } return(model); }