public async Task <IResponse> Handle(CreateBuyListCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados da lista inválidos", command.Notifications)); } var user = await _userRepository.GetById(new Guid(command.OwnerId)); if (user == null) { return(new GenericCommandResult(false, "Usuário inválido", user)); } var buyList = new ListBuy(command.Name, command.Date, user); await _buyListRepository.Create(buyList); return(new GenericCommandResult(true, "Ok", buyList)); }
public async Task Delete(ListBuy buyList) { _context.ListBuy.Remove(buyList); await _context.SaveChangesAsync(); }
public async Task Update(ListBuy buyList) { _context.Entry(buyList).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task Create(ListBuy buyList) { _context.ListBuy.Add(buyList); await _context.SaveChangesAsync(); }
public BuyListTests() { _owner = new User("Jean Fernandes", "*****@*****.**", "123456"); _validBuyList = new ListBuy("Lista de compras da tarde", new DateTime(), _owner); }
public Task Delete(ListBuy buyList) { return(Task.FromResult(0)); }