public async Task <ActionResult> MakeNoteDone(int id) { //Todo: shoud apply patch later var reponse = await SecuredNotesClient.GetAsync(string.Format("api/notes/{0}", id)).ConfigureAwait(false); if (reponse.IsSuccessStatusCode) { var stringContent = await reponse.Content.ReadAsStringAsync().ConfigureAwait(false); var note = JsonConvert.DeserializeObject <EditNoteDto>(stringContent); note.IsDone = true; var putStringContent = new StringContent(JsonConvert.SerializeObject(note), Encoding.Unicode, "application/json"); reponse = await SecuredNotesClient.PutAsync(string.Format("api/notes/{0}", id), putStringContent).ConfigureAwait(false); if (reponse.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View("Error", new HandleErrorInfo(ExceptionHelper.GetExceptionFromResponse(reponse), "Notes", "Index"))); }
public async Task <ActionResult> Edit(int id, EditNoteDto noteDto) { var stringContent = new StringContent(JsonConvert.SerializeObject(noteDto), Encoding.Unicode, "application/json"); var reponse = await SecuredNotesClient.PutAsync(string.Format("api/notes/{0}", id), stringContent).ConfigureAwait(false); if (reponse.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View("Error", new HandleErrorInfo(ExceptionHelper.GetExceptionFromResponse(reponse), "Notes", "Index"))); }