Example #1
0
        public GameTab(Gry game) {
            InitializeComponent();

            this.game = game;
            labelTitle.Content = game.Tytul;
            string genres = "";
            foreach(var genre in game.Gatunki.Select(x => x.Nazwa)) {
                genres += genre + " ";
            }
            labelGenre.Content = genres;
            if (game.OcenyGier.Count > 0) {
                labelRate1.Content = game.OcenyGier.Average(x => x.OcenaOgolna).ToString();
                labelRankPosition.Content = "Pozycja w rankingu: " + DatabaseManager.Entities.getRankPosition(game.GraID).First().Value;
            } else {
                labelRate1.Content = "n";
                labelRankPosition.Content = "Brak ocen.";
            }
            labelDescription.Content = game.Opis;
            ratePicker.Game = game;

            RefreshComments();
            RefreshReviews();
        }
Example #2
0
        private void AddGame(object obj)
        {
            try
            {

                Action<string, string> okString =
                    (str, msg) => {
                        if (str == null || str == "")
                            throw new EValidData(msg);
                    };

                Console.WriteLine(NewGameName);
                okString(NewGameName, "Niepoprawna nazwa gry.");
                okString(NewGameStudioName, "Niepoprawna nazwa studio.");

                if (DatabaseManager.Entities.Gry.Any(x=> x.Tytul == NewGameName))
                    throw new EValidData("Gra podanej nazwie już istnieje.");

                if (!(DatabaseManager.Entities.Studia.Any(x => x.Nazwa == NewGameStudioName)))
                {
                    var newStudio  = new Studia();
                    newStudio.Nazwa = NewGameStudioName;
                    DatabaseManager.Entities.Studia.Add(newStudio);
                    DatabaseManager.Save();
                }

                var studio = DatabaseManager.Entities.Studia.First(x => x.Nazwa == NewGameStudioName);

                var game = new Gry()
                {
                    Tytul = NewGameName,
                    StudioID = studio.StudioID,
                    DataWydania = (DateTime)NewGameRelease,
                    Opis = NewGameDescription,
                };

                var gatunek = DatabaseManager.Entities.Gatunki.First(x => x.Nazwa == GenreSelected);
                gatunek.Gry.Add(game);

                DatabaseManager.Entities.Gry.Add(game);
                DatabaseManager.Save();

                DialogManager.ShowInfoDialog("Dodawanie gry", "Gra została dodana pomyślnie!");
            }
            catch (EValidData e)
            {
                DialogManager.ShowErrorDialog("Błędne dane", e.Message);
            }
            catch (Exception)
            {
                DialogManager.ShowErrorDialog("Błędne dane", "Sprawdź wpisane dane");
            }

        }
Example #3
0
 public NewReviewWindow(Gry game)
 {
     InitializeComponent();
     Title += "(" + game.Tytul + ")";
     this.game = game;
 }