Exemple #1
0
        public async Task <ICommandResult> Handle(DeleteDeveloperCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Operação inválida", command.Notifications));
            }

            var developerDb = await _developerRepository.GetByIdAsync(command.Id);

            if (developerDb == null)
            {
                return(new GenericCommandResult(false, "Desenvolvedor não encontrado", command.Notifications));
            }


            await _developerRepository.DeleteAsync(command.Id);

            return(new GenericCommandResult(true, "Desenvolvedor removido com sucesso", developerDb));
        }
 public async Task <GenericCommandResult> Delete([FromBody] DeleteDeveloperCommand command, [FromServices] DeveloperHandler handler)
 {
     return((GenericCommandResult)await handler.Handle(command));
 }