public async Task <IResponse> Handle(DeleteBuyListCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados da lista inválidos!", command.Notifications)); } var list = await _buyListRepository.GetById(command.Id); if (list == null) { return(new GenericCommandResult(false, "Lista inválida!", list)); } await _buyListRepository.Delete(list); return(new GenericCommandResult(true, "Ok", list)); }
public async Task <GenericCommandResult> Delete([FromBody] DeleteBuyListCommand command, [FromServices] BuyListHandler handler) { return((GenericCommandResult)await handler.Handle(command)); }