public async Task <IActionResult> Delete(int id) { if (await _characterRepository.GetByIdAsync(id) is Character character) { await _characterRepository.DeleteAsync(character); return(NoContent()); // 204 } return(NotFound()); }
public async Task <IActionResult> Delete(int id) { var deleted = await _repository.DeleteAsync(id); if (!deleted) { return(NotFound()); } return(NoContent()); }
public async Task <DefaultResultMessage> DeleteAsync(string id) { var deleteResult = await _characterRepository.DeleteAsync(id); var defaultResult = new DefaultResultMessage(); if (deleteResult) { defaultResult.SetMessage(CommonMessages.ReccordsDeleted); defaultResult.IsSuccess(); } else { defaultResult.SetMessage(string.Format(CharacterMessages.NotExistsIdInDatabase, id)); } return(defaultResult); }
public async Task <Unit> Handle(DeleteCharacterCommand request, CancellationToken cancellationToken) { await _characterRepository.DeleteAsync(request.CharacterId); return(Unit.Value); }