/// <summary> /// Deletes a post with a given id /// </summary> /// <param name="actualRequest">the client request to be handled</param> /// <returns>the response to the given request</returns> private async Task <ActualRequest> DeletePostAsync(ActualRequest actualRequest) { Request request = actualRequest.Request; int postId = Convert.ToInt32(request.Argument.ToString()); Console.WriteLine("Deleting post with id " + postId); bool response = await postRepo.DeletePostAsync(postId); if (response) { ImagesUtil.DeleteFile($"{FILE_PATH}/Posts", $"{postId}.jpg"); } Request responseRequest = new Request { ActionType = ActionType.POST_DELETE.ToString(), Argument = JsonSerializer.Serialize(response) }; return(new ActualRequest { Request = responseRequest, Images = null }); }
public async Task <IActionResult> Delete(int id) { await _postRepo.DeletePostAsync(id); return(Ok()); }
public async Task <bool> DeletePostAsync(Post post) { return(await _repo.DeletePostAsync(post)); }