public async Task <CreateUpdatePostResponse> CreateAsync(CreateUpdatePostDto createdPost) { var uploadedfile = createdPost.PhotoFile; var documentDto = new DocumentDto { FileName = uploadedfile.FileName, TypeFile = uploadedfile.GetType().ToString(), Url = documentAppService.CreateDocumentUrl(uploadedfile) }; var createdFile = await documentAppService.CreateAsync(documentDto); createdPost.PhotoPath = createdFile.Id.ToString(); var result = await postAppService.CreatePost(createdPost); var response = new CreateUpdatePostResponse { postDto = null }; if (result) { response.IsSuccess = true; } else { response.IsSuccess = false; response.Errors = new string[] { "Create post failed!" }; } return(response); }
public async Task <CreateUpdatePostResponse> DeleteAsync(Guid postid) { var result = await postAppService.DeletePost(postid); var response = new CreateUpdatePostResponse(); if (result) { response.IsSuccess = true; } else { response.IsSuccess = false; response.Errors = new string[] { "Delete Fail!" }; } return(response); }
public async Task <CreateUpdatePostResponse> UpdateAsync(CreateUpdatePostDto updatedPost, Guid postId) { updatedPost.Id = postId; var result = await postAppService.UpdatePost(updatedPost); var response = new CreateUpdatePostResponse(); response.postDto = updatedPost; if (result) { response.IsSuccess = true; } else { response.IsSuccess = false; response.Errors = new string[] { "Update Fail!" }; } return(response); }