public SmsLog UpdateSingle(int id, SmsLogReq data) { SmsLog model = db.SmsLog.Find(id); SetSmsLog(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public SmsLog SetSmsLog(SmsLog model, SmsLogReq data) { if (!string.IsNullOrEmpty(data.Type)) { model.Type = data.Type; } if (data.RefId != null) { model.RefId = data.RefId.Value; } if (data.SendDate != null && data.SendDate != DateTime.MinValue && data.SendDate != SqlDateTime.MinValue.Value) { model.SendDate = data.SendDate.Value; } if (!string.IsNullOrEmpty(data.Result)) { model.Result = data.Result; } if (!string.IsNullOrEmpty(data.SmsMsg)) { model.SmsMsg = data.SmsMsg; } if (!string.IsNullOrEmpty(data.RetCode)) { model.RetCode = data.RetCode; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (data.projectid != null) { model.projectid = data.projectid.Value; } if (!string.IsNullOrEmpty(data.ToPhones)) { model.ToPhones = data.ToPhones; } if (!string.IsNullOrEmpty(data.RefTitle)) { model.RefTitle = data.RefTitle; } return(model); }