示例#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());
            }
        }
示例#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));
            }
        }
示例#3
0
 public void Delete(int id)
 {
     _repository.Delete(id);
 }
示例#4
0
 public ICommandResult Handle(DeleteHeroCommand command)
 {
     return(_heroesRepository.Delete(command));
 }
示例#5
0
        public async Task <IActionResult> Delete(int id)
        {
            await _heroesRepository.Delete(id);

            return(Accepted());
        }