public async Task <IResponse> Handle(UpdateBuyListCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados da lista inválidos", command.Notifications)); } var buyList = await _buyListRepository.GetById(command.Id); if (buyList == null) { return(new GenericCommandResult(false, "Lista inválida", buyList)); } buyList.UpdateBuyList(command.Name, command.Date); await _buyListRepository.Update(buyList); return(new GenericCommandResult(true, "Ok", buyList)); }
public UpdateBuyListHandlerTests() { _validCommand = new UpdateBuyListCommand(new Guid(), "Lista de compras da tarde", DateTime.Now); }
public UpdateBuyListCommandTests() { _validCommand = new UpdateBuyListCommand(new Guid(), "Lista de compras da tarde", DateTime.Now); this._validCommand.Validate(); }
public async Task <GenericCommandResult> Update([FromBody] UpdateBuyListCommand command, [FromServices] BuyListHandler handler) { return((GenericCommandResult)await handler.Handle(command)); }