public UserModel GetUser(String username, bool isLogged) { var user = usersRepository.GetUser(username); if (user == null) { throw new ObjectNotFoundException(string.Format("No such user '{0}'", username)); } var userModel = new UserModel(user); betsRepository.GetUserBets(user.UserName).Where(bet => isLogged || !bet.IsOpenForBetting(dateTimeProvider.UTCNow)).ToList().ForEach(bet => userModel.AddBet(new BetViewModel(bet, dateTimeProvider.UTCNow))); var generalBet = generalBetsRepository.GetUserGeneralBet(username); if (generalBet != null) { userModel.SetGeneralBet(new GeneralBetViewModel(generalBet)); } return(userModel); }