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

            var timeSheetDb = await _timeSheetRepository.GetByIdAsync(command.Id);

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


            await _timeSheetRepository.DeleteAsync(command.Id);

            return(new GenericCommandResult(true, "Desenvolvedor removido com sucesso", timeSheetDb));
        }
Esempio n. 2
0
 public async Task <GenericCommandResult> Delete([FromBody] DeleteTimeSheetCommand command, [FromServices] TimeSheetHandler handler)
 {
     return((GenericCommandResult)await handler.Handle(command));
 }