public JmsDirectory UpdateSingle(int id, JmsDirectoryReq data) { JmsDirectory model = db.JmsDirectory.Find(id); SetJmsDirectory(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JmsDirectory SetJmsDirectory(JmsDirectory model, JmsDirectoryReq data) { if (data.ParentId != null) { model.ParentId = data.ParentId.Value; } if (!string.IsNullOrEmpty(data.ParentName)) { model.ParentName = data.ParentName; } if (!string.IsNullOrEmpty(data.Name)) { model.Name = data.Name; } if (!string.IsNullOrEmpty(data.Right)) { model.Right = data.Right; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (!string.IsNullOrEmpty(data.DirectoryPath)) { model.DirectoryPath = data.DirectoryPath; } if (!string.IsNullOrEmpty(data.JmsUploadClassState)) { model.JmsUploadClassState = data.JmsUploadClassState; } if (data.JmsId != null) { model.JmsId = data.JmsId.Value; } if (!string.IsNullOrEmpty(data.JmsName)) { model.JmsName = data.JmsName; } return(model); }