public async Task <ValidationResult> Handle(UpdateGameLendCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { return(message.ValidationResult); } var gameLend = new GameLendModel(Guid.NewGuid(), message.IdGame, message.IdPerson, message.LendOn, message.ReturnedOn, message.Created, message.Updated); gameLend.AddDomainEvent(new GameLendRegisteredEvent(gameLend.IdPerson, gameLend.IdGame, gameLend.LendOn, gameLend.ReturnedOn, gameLend.Created, gameLend.Updated)); _gameLendRepository.Add(gameLend); return(await Commit(_gameLendRepository.UnitOfWork)); }
public async Task <ValidationResult> Handle(RegisterNewGameLendCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { return(message.ValidationResult); } var gameLend = new GameLendModel(Guid.NewGuid(), message.IdGame, message.IdPerson, message.LendOn, message.ReturnedOn, message.Created, message.Updated); if (_gameLendRepository.GameIsAvailable(gameLend.IdGame) == false) { AddError("Game já emprestado."); return(ValidationResult); } gameLend.AddDomainEvent(new GameLendRegisteredEvent(gameLend.IdPerson, gameLend.IdGame, gameLend.LendOn, gameLend.ReturnedOn, gameLend.Created, gameLend.Updated)); _gameLendRepository.Add(gameLend); return(await Commit(_gameLendRepository.UnitOfWork)); }
public void Remove(GameLendModel entity) { DbSet.Remove(entity); }
public void Update(GameLendModel entity) { DbSet.Update(entity); }
public void Add(GameLendModel entity) { DbSet.Add(entity); }