/// TODO: Make it so you cannot delete the home page (deleting the home page will cause a 404) /// or re-factor to make the home page dynamic or configurable. public async Task <IActionResult> OnGetAsync(string slug) { if (slug == null) { return(NotFound()); } var article = await _mediator.Send(new GetArticleQuery(slug)); if (article == null) { return(NotFound()); } if (article.IsHomePage) { await _mediator.Publish(new DeleteHomePageAttemptNotification()); return(Forbid()); } Article = _mapper.Map <ArticleDelete>(article); return(Page()); }
public async Task <IActionResult> Delete(Guid id, [FromQuery] ArticleDelete request) { var found = await Mediator.Send(request with { Id = id, UserId = RequestUserId, }); if (!found) { return(NotFound()); } await SaveChangesAsync(); return(NoContent()); }