Beispiel #1
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var hero = await _heroesRepository.GetByIdAsync(id);

            if (hero != null)
            {
                _heroesRepository.Delete(hero);
                await _heroesRepository.SaveAsync();

                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Delete(Guid key)
        {
            try
            {
                var heroEntity = await _heroesRepository.Find(key).ConfigureAwait(false);

                if (heroEntity == null)
                {
                    return(NotFound());
                }

                await _heroesRepository.Delete(key).ConfigureAwait(false);

                return(StatusCode(Status204NoContent));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Failure on hero.");
                return(StatusCode(Status500InternalServerError));
            }
        }
Beispiel #3
0
 public void Delete(int id)
 {
     _repository.Delete(id);
 }
Beispiel #4
0
 public ICommandResult Handle(DeleteHeroCommand command)
 {
     return(_heroesRepository.Delete(command));
 }
Beispiel #5
0
        public async Task <IActionResult> Delete(int id)
        {
            await _heroesRepository.Delete(id);

            return(Accepted());
        }