public HuoPingRukuDan UpdateSingle(int id, HuoPingRukuDanReq data) { HuoPingRukuDan model = db.HuoPingRukuDan.Find(id); SetHuoPingRukuDan(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public HuoPingRukuDan SetHuoPingRukuDan(HuoPingRukuDan model, HuoPingRukuDanReq data) { if (!string.IsNullOrEmpty(data.RuKuDanBianHao)) { model.RuKuDanBianHao = data.RuKuDanBianHao; } if (data.HPCount != null) { model.HPCount = data.HPCount.Value; } if (data.HPZhongLei != null) { model.HPZhongLei = data.HPZhongLei.Value; } if (data.HPZongJia != null) { model.HPZongJia = data.HPZongJia.Value; } if (!string.IsNullOrEmpty(data.RuKuDanState)) { model.RuKuDanState = data.RuKuDanState; } if (data.RuKuDate != null && data.RuKuDate != DateTime.MinValue && data.RuKuDate != SqlDateTime.MinValue.Value) { model.RuKuDate = data.RuKuDate.Value; } if (!string.IsNullOrEmpty(data.optName)) { model.optName = data.optName; } if (data.optDateTime != null && data.optDateTime != DateTime.MinValue && data.optDateTime != SqlDateTime.MinValue.Value) { model.optDateTime = data.optDateTime.Value; } if (data.RuKuDanLeiXing != null) { model.RuKuDanLeiXing = data.RuKuDanLeiXing.Value; } if (data.CaiGouDanId != null) { model.CaiGouDanId = data.CaiGouDanId.Value; } return(model); }