public void showLib() { if (userLib == null) { userLib = new ObservableCollection <Game>(); } //this.LibraryUser.UserLibrary.Clear(); //_userRepo.UpdateUser(this.LibraryUser); //foreach(var libItm in _userRepo.getUserByLogin(this.LibraryUser.Login).UserLibrary) //{ // if (_gameRepo.FindById(libItm.GameId) == _gameRepo.FindByFullName("CSGO")) // { // } // else // { // _buyService.BuyGame(_gameRepo.FindByFullName("CSGO"), this.LibraryUser); // } //} userLib.Clear(); foreach (var libItm in _userRepo.getUsrDetails(LibraryUser.Id).UserLibrary) { userLib.Add(_gameRepo.FindById(libItm.GameId)); } //LibraryLIst.Items.Clear(); LibraryLIst.ItemsSource = userLib; }
public LibraryPage(IGameRepo gameRepo, IUserRepo userRepo, IBuyService buyService, IPriceCalculationStrategy calcStrat, StorePage sp, User ActiveUser) { this._gameRepo = gameRepo; this._userRepo = userRepo; this._buyService = buyService; this._calcStrat = calcStrat; this.LibraryUser = ActiveUser; if (sp == null) { stp = new StorePage(_gameRepo, _userRepo, _buyService, _calcStrat, this, this.LibraryUser); } else { stp = sp; } InitializeComponent(); if (userLib == null) { userLib = new ObservableCollection <Game>(); } //this.LibraryUser.UserLibrary.Clear(); //_userRepo.UpdateUser(this.LibraryUser); //foreach(var libItm in _userRepo.getUserByLogin(this.LibraryUser.Login).UserLibrary) //{ // if (_gameRepo.FindById(libItm.GameId) == _gameRepo.FindByFullName("CSGO")) // { // } // else // { // _buyService.BuyGame(_gameRepo.FindByFullName("CSGO"), this.LibraryUser); // } //} userLib.Clear(); foreach (var libItm in userRepo.getUsrDetails(LibraryUser.Id).UserLibrary) { userLib.Add(_gameRepo.FindById(libItm.GameId)); } LibraryLIst.Items.Clear(); LibraryLIst.ItemsSource = userLib; //foreach (var itm in _userRepo.getUsrDetails(LibraryUser.Id).UserLibrary) //{ // int i = 0; // LibraryLIst.Resources.Add(i, _gameRepo.FindById(itm.GameId).Name); // i++; //} }