コード例 #1
0
 public GenericCommandResult Delete(
     [FromBody] DeleteSchoolCommand command,
     [FromServices] SchoolHandler handler
     )
 {
     return((GenericCommandResult)handler.Handle(command));
 }
コード例 #2
0
        public ICommandResult Delete(Guid id)
        {
            DeleteSchoolCommand command = new DeleteSchoolCommand();

            command.Id = id;
            var result = (CommandResult)_handler.Handle(command);

            return(result);
        }
コード例 #3
0
        public ICommandResult Handle(DeleteSchoolCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que os dados da escola estão errados!", command.Notifications));
            }

            // Recupera
            var school = _repository.GetById(command.Id);

            // apaga no banco
            _repository.Delete(school);

            // Retorna o resultado
            return(new GenericCommandResult(true, "Escola apagada com sucesso!", school));
        }
コード例 #4
0
        // Excluir uma escola
        public ICommandResult Handle(DeleteSchoolCommand command)
        {
            // Valida os dados do command
            command.Validate();
            // Se for invalido, mostrar as notificações
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, SharedMessages.InvalidOperation, command));
            }

            // Deletando as  informações
            _schoolRepository.Remove(command.Id);

            // Realizando a exclusão do banco de dados
            _uow.Commit();

            // Retornando informações de sucesso e o objeto preenchido
            return(new CommandResult(true, SharedMessages.SuccedOperation, command.Id));
        }
コード例 #5
0
 public async Task <ActionResult <DeleteSchoolCommandResponse> > Delete(DeleteSchoolCommand request, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Send(request, cancellationToken));
 }