private void UpdateGameLoan(GameLoan gameLoan) { var currentGameLoan = GetCurrentGameLoan(gameLoan.Id); //If the game is being changed if (gameLoan.GameId != currentGameLoan.GameId) { //Releasing current game var loanedGame = GameRepository.FindGamesById(currentGameLoan.GameId); loanedGame.IsLent = false; GameRepository.Update(loanedGame); var game = GameRepository.FindGamesById(gameLoan.GameId); ValidateGameLoan(gameLoan, game); gameLoan.LoanDate = currentGameLoan.LoanDate; GameRepository.Update(loanedGame); GameLoanRepository.Update(gameLoan); } else { var game = GameRepository.FindGamesById(gameLoan.GameId); gameLoan.LoanDate = currentGameLoan.LoanDate; GameLoanRepository.Update(gameLoan); } }
private void RegisterGameReturn(GameLoan gameLoan) { var currentGameLoan = GetCurrentGameLoan(gameLoan.Id); if (currentGameLoan.IsActive) { var loanedGame = GameRepository.FindGamesById(currentGameLoan.GameId); loanedGame.IsLent = false; gameLoan.IsActive = false; gameLoan.LoanDate = currentGameLoan.LoanDate; gameLoan.ReturnDate = DateService.GetCurrentDate(); GameRepository.Update(loanedGame); GameLoanRepository.Update(gameLoan); } }