public GenericCommandResult Delete( [FromBody] DeleteSchoolCommand command, [FromServices] SchoolHandler handler ) { return((GenericCommandResult)handler.Handle(command)); }
public ICommandResult Delete(Guid id) { DeleteSchoolCommand command = new DeleteSchoolCommand(); command.Id = id; var result = (CommandResult)_handler.Handle(command); return(result); }
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)); }
// 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)); }
public async Task <ActionResult <DeleteSchoolCommandResponse> > Delete(DeleteSchoolCommand request, CancellationToken cancellationToken = default(CancellationToken)) { return(await Send(request, cancellationToken)); }