public ContentUpdateResponse Update(string id, [FromBody] ContentUpdateRequest contentUpdateRequest) { try { var dbContent = new DbContent { Author = HttpContextUtility.LoggedUserIdentity(), Type = contentUpdateRequest.Content.Type, Locale = contentUpdateRequest.Content.Locale, Published = contentUpdateRequest.Content.Published, Title = contentUpdateRequest.Content.Title, Subtitle = contentUpdateRequest.Content.Subtitle, HtmlContent = contentUpdateRequest.Content.HtmlContent, TextContent = contentUpdateRequest.Content.TextContent }; var updatedContent = _contentService.Update(id, dbContent); return(new ContentUpdateResponse { Content = updatedContent.MapToContent() }); } catch (Exception ex) { return(new ContentUpdateResponse { Success = false, Message = ex.Message }); } }
public async Task <ContentUpdateResponse> Update(ContentUpdateRequest contentUpdateRequest) { var baseApiResult = await PutRequest <ContentUpdateResponse>($"Content/Update/{contentUpdateRequest.Content.Id}", contentUpdateRequest); if (!baseApiResult.Success) { throw new Exception(baseApiResult.Message); } return(baseApiResult.Response); }
public async Task <IActionResult> OnPost(string id) { var updateRequest = new ContentUpdateRequest { Content = ContentForm.Content }; var result = await _contentApiService.Update(updateRequest); if (result.Success) { return(RedirectToPage(ContentForm.SuccessPage, new { Area = ContentForm.SuccessArea })); } return(RedirectToPage(ContentForm.FailurePage, new { Area = ContentForm.FailureArea })); }