Ejemplo n.º 1
0
        public void GetSelectedGameData(string GameID)
        {
            this.game = this.Data.GetGameData(GameID);
            this.SelectedGame = new GameViewModel(this.game);
            Debug.WriteLine("Selected game id is "+SelectedGame.ID);
            if (string.IsNullOrEmpty(this.SelectedGame.Description))
            {
                this.SelectedGame.Description = N0_DESCRIPTION;
            }
            if (string.IsNullOrEmpty(selectedGame.Notes))
            {
                this.SelectedGame.Notes = N0_NOTES;
            }

            Collections = new ObservableCollection<Collection>();
        }
Ejemplo n.º 2
0
        private static bool GameAlreadyInCollection(GameData game, int collectionID)
        {
            bool result = false;

            using (GameDataContext context = new GameDataContext(Constants.DBConnectionString))
            {
                IQueryable<GameCollection> query = from c in context.CollectionManager
                                               where c.CollectionID == collectionID && c.GameID == game.ID
                                               select c;

                result = (query.FirstOrDefault() != null);
            }
            return result;
        }
Ejemplo n.º 3
0
        public static void AddGameToCollection(GameData game, int collectionID)
        {
            if (GameAlreadyInCollection(game, collectionID))
            {
                return;
            }

            //GetDataBase();
            using (GameDataContext context = new GameDataContext(Constants.DBConnectionString))
            {
                IQueryable<Collection> query = from c in context.Collection
                                               where c.ID == collectionID
                                               select c;


                Collection collection = query.FirstOrDefault();

                GameData foundGame = GetGameData(game.ID.ToString());

                GameCollection collectionManager = new GameCollection();
                
                collectionManager.GameID = foundGame.ID;
                collectionManager.CollectionID = collection.ID;

                game.GameCollections.Add(collectionManager);
                collection.GameCollections.Add(collectionManager);

                context.CollectionManager.InsertOnSubmit(collectionManager);
                context.SubmitChanges();
            }
        }
Ejemplo n.º 4
0
        public static void ProccessImages(GameData game, List<GameImage> imageList)
        {
            ObservableCollection<BitmapImage> result = new ObservableCollection<BitmapImage>();

            foreach (GameImage item in imageList)
            {
                using (var ms = new MemoryStream(item.Image))
                {
                    var bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(ms);

                    game.Images.Add(bitmapImage);
                }
            }
        }
Ejemplo n.º 5
0
        public GameViewModel(GameData gamedata)
        {
            this.images = new ObservableCollection<BitmapImage>();

            this.ID = gamedata.ID;
            this.UKName = gamedata.UK_Name;
            this.Description = gamedata.Description;
            this.Notes = gamedata.Notes;

            this.platform = gamedata.Platform;

            this.Images = new ObservableCollection<BitmapImage>(gamedata.Images); 
            //ProccessImages(gamedata.GameImages);
            GetPlatformIcon();
        }
Ejemplo n.º 6
0
 public void AddGameToCollection(int collectionID, GameData game)
 {
     DatabaseFunctions.AddGameToCollection(game, collectionID);
 }
Ejemplo n.º 7
0
        private void HandleGameData(GameList gamesList, Exception exception)
        {
            ObservableCollection<GameData> gameDataList = new ObservableCollection<GameData>();
            if (exception == null)
            {
                GameDataContext context = new GameDataContext(Constants.DBConnectionString);
                foreach (GameResponse g in gamesList.Games)
                {
                    GameData game = new GameData(g, this.SelectedPlatform);
                    gameDataList.Add(game);
                    Debug.WriteLine("Adding " + game.UK_Name);
                    context.Games.InsertOnSubmit(game);
                }
                context.SubmitChanges();
            }
#if DEBUG
            PrintOutGameData(gamesList);
#endif
            if (this.CallBack != null)
            {
                CallBack(gameDataList, exception);    
            }
        }