public async Task <Unit> Handle(DeleteQuestionCommand request, CancellationToken cancellationToken) { _writeQuestionRepository.Delete(request.Id); await _writeQuestionRepository.SaveChangesAsync(); return(Unit.Value); }
public ActionResult <Question> Delete(Guid id) { if (!_readQuestionRepository.Exists(id)) { return(NotFound()); } this.HttpContext.Items.TryGetValue("UserId", out var userId); if (!_readQuestionRepository.GetOwnerById(id).ToString().Equals(userId)) { return(BadRequest("You dont have owner privileges for this question.")); } _writeQuestionRepository.Delete(id); _writeQuestionRepository.SaveChanges(); return(NoContent()); }