public ActionResult Update(UpdateDocumentInput input) { IWikiDocumentAppService service = this.CreateService <IWikiDocumentAppService>(); service.Update(input); return(this.SuccessMsg("更新成功")); }
public void Update(UpdateDocumentInput input) { input.Validate(); DateTime updationTime = DateTime.Now; this.DbContext.Update <WikiDocumentDetail>(a => a.Id == input.Id, a => new WikiDocumentDetail() { Title = input.Title, Summary = input.Summary, HtmlContent = input.HtmlContent, MarkdownCode = input.MarkdownCode, Tag = input.Tag, UpdationTime = updationTime }); }
//[System.Web.Mvc.ValidateInput(false)] public ActionResult Update(UpdateDocumentInput input) { this.Service.Update(input); return(this.SuccessMsg("更新成功")); }
public ShareLinkItem updateBookmark(String key, Uri link, String title, String description, List <String> spaceKeys, Bitmap icon) { try { LinkApi linkApi = new LinkApi(session.GetApiClient()); DocumentApi documentApi = new DocumentApi(session.GetApiClient()); GetLinkResult getLinkResult = linkApi.GetLink(key); if (getLinkResult.Hdr.Rc == 0) { LinkV2Record existingLink = getLinkResult.Link; existingLink.Link = link.ToString(); existingLink.Title = title; existingLink.Text = description; existingLink.Type = "link"; //UpdateLinkInput updateLinkInput = new UpdateLinkInput(existingLink); //UpdateLinkResult updateLinkResult = linkApi.UpdateLink(key, updateLinkInput); UpdateDocumentInput updateDocumentInput = new UpdateDocumentInput(existingLink); UpdateDocumentResult updateDocumentResult = documentApi.UpdateDocument(key, updateDocumentInput); if (updateDocumentResult.Hdr.Rc == 0) { DocumentV2Record updatedDocument = updateDocumentResult.Document; SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); // Remove spaces foreach (DisplayRecord destination in updatedDocument.Destinations) { if (!spaceKeys.Contains(destination.Key)) { List <String> itemKeysToRemove = new List <String>() { updatedDocument.Key }; RemoveObjectsInput removeObjectsInput = new RemoveObjectsInput(destination.Key, itemKeysToRemove); RemoveObjectsResult removeObjectsResult = spaceApi.RemoveObjects(destination.Key, removeObjectsInput); if (removeObjectsResult.Hdr.Rc != 0) { throw new Exception("Vmoso error removing bookmark from space. Rc=" + removeObjectsResult.Hdr.Rc); } } else { spaceKeys.Remove(destination.Key); } } if (spaceKeys.Count > 0) { ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(updatedDocument.Key, shareInput); if (shareResult.Hdr.Rc != 0) { throw new Exception("Vmoso error sharing bookmark. Rc=" + shareResult.Hdr.Rc); } } getLinkResult = linkApi.GetLink(updatedDocument.Key); if (getLinkResult.Hdr.Rc == 0) { LinkV2Record updatedLink = getLinkResult.Link; ShareLinkItem item = new ShareLinkItem(updatedLink.Title, updatedLink.Text); item.Key = updatedLink.Key; item.Link = new Uri(updatedLink.Link); item.Record = updatedLink; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in updatedLink.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error getting updated link. Rc=" + getLinkResult.Hdr.Rc); } } else { throw new Exception("Vmoso error updating link. Rc=" + updateDocumentResult.Hdr.Rc); } } else { throw new Exception("Vmoso error getting link to update. Rc=" + getLinkResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso error getting link to update", ex); } }
public void Update(UpdateDocumentInput input) { input.Validate(); this.DbContext.UpdateFromDto<WikiDocumentDetail, UpdateDocumentInput>(input); }
/// <summary> /// update document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key"></param> /// <param name="input">UpdateDocument Input</param> /// <returns>ApiResponse of UpdateDocumentResult</returns> public ApiResponse <UpdateDocumentResult> UpdateDocumentWithHttpInfo(string key, UpdateDocumentInput input) { // verify the required parameter 'key' is set if (key == null) { throw new ApiException(400, "Missing required parameter 'key' when calling DocumentApi->UpdateDocument"); } // verify the required parameter 'input' is set if (input == null) { throw new ApiException(400, "Missing required parameter 'input' when calling DocumentApi->UpdateDocument"); } var localVarPath = "/documentsV2/{key}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (key != null) { localVarPathParams.Add("key", Configuration.ApiClient.ParameterToString(key)); // path parameter } if (input != null && input.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(input); // http body (model) parameter } else { localVarPostBody = input; // byte array } // authentication (vmoso_auth) required if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("X-CV-Authorization"))) { localVarHeaderParams["X-CV-Authorization"] = Configuration.GetApiKeyWithPrefix("X-CV-Authorization"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("UpdateDocument", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <UpdateDocumentResult>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (UpdateDocumentResult)Configuration.ApiClient.Deserialize(localVarResponse, typeof(UpdateDocumentResult)))); }
/// <summary> /// update document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key"></param> /// <param name="input">UpdateDocument Input</param> /// <returns>UpdateDocumentResult</returns> public UpdateDocumentResult UpdateDocument(string key, UpdateDocumentInput input) { ApiResponse <UpdateDocumentResult> localVarResponse = UpdateDocumentWithHttpInfo(key, input); return(localVarResponse.Data); }
/// <summary> /// update document /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key"></param> /// <param name="input">UpdateDocument Input</param> /// <returns>Task of UpdateDocumentResult</returns> public async System.Threading.Tasks.Task <UpdateDocumentResult> UpdateDocumentAsync(string key, UpdateDocumentInput input) { ApiResponse <UpdateDocumentResult> localVarResponse = await UpdateDocumentAsyncWithHttpInfo(key, input); return(localVarResponse.Data); }