Esempio n. 1
0
        public void AddGenresToList(IEnumerable <GnApiProgramsSchema.programsProgramGenre> genres, string apiLevel, bool updateTracker = false)
        {
            var programsProgramGenres = genres.ToList();

            if (programsProgramGenres.Any())
            {
                if (GenresList == null)
                {
                    GenresList = new List <GnApiProgramsSchema.programsProgramGenre>();
                }
                if (!updateTracker)
                {
                    Log.Debug($"Number of Genres at {apiLevel} Level: {programsProgramGenres.Count()}");
                }

                foreach (var genre in programsProgramGenres)
                {
                    GenresList.Add(genre);
                }
            }
            else
            {
                if (!updateTracker)
                {
                    Log.Warn($"Genre info is currently null at the current api level: {apiLevel}, " +
                             "will continue and check next api results for genre data");
                }
            }
        }
Esempio n. 2
0
        public AddGame(Games game)
        {
            InitializeComponent();
            rate_IgromaniaLabel.Text = string.Format("Рейтинг {0}:", Settings.Default.Recenzor);
            label3.Text            = Settings.Default.DistrReg;
            PersonRate.Maximum     = Settings.Default.MaxYourRating;
            numericUpDown2.Maximum = Settings.Default.MaxRecenzorRating;

            PlatformsList.DataSource    = platformsBindingSource;
            PlatformsList.DisplayMember = "Name";
            PlatformsList.ValueMember   = "ID_Platform";
            PlatformsList.DataSource    = _context.Platforms.ToList();

            OnlineProtectionsList.DataSource    = online_protectionsBindingSource;
            OnlineProtectionsList.DisplayMember = "Name";
            OnlineProtectionsList.ValueMember   = "ID_Protect";
            OnlineProtectionsList.DataSource    = _context.Online_protections.ToList();

            GenresList.DataSource    = genresBindingSource;
            GenresList.DisplayMember = "Name";
            GenresList.ValueMember   = "ID_Genre";
            GenresList.DataSource    = _context.Genres.ToList();

            DiskTypes.DataSource = _context.Disk_types.ToList();

            var LP = new List <Publishers> {
                new Publishers {
                    Name = "<отсутствует>", Id_Publisher = 0
                }
            };

            LP.AddRange(_context.Publishers.OrderBy(p => p.Name).ToArray());
            comboBox2.DataSource = LP;

            var LD = new List <Developers> {
                new Developers {
                    Name = "<отсутствует>", ID_Developer = 0
                }
            };

            LD.AddRange(_context.Developers.OrderBy(d => d.Name).ToArray());
            comboBox1.DataSource = LD;

            var LRF = new List <RF_Distributors> {
                new RF_Distributors {
                    Name = "<отсутствует>", ID_RF_Distributor = 0
                }
            };

            LRF.AddRange(_context.RF_Distributors.OrderBy(r => r.Name).ToArray());
            comboBox3.DataSource = LRF;

            var LS = new List <Series> {
                new Series {
                    Name = "<отсутствует>", ID_Ser = 0
                }
            };

            LS.AddRange(_context.Series.OrderBy(s => s.Name).ToArray());
            comboBox8.DataSource = LS;

            var le = new List <Editions> {
                new Editions {
                    Name = "<отсутствует>", ID_Edition = 0
                }
            };

            le.AddRange(_context.Editions.ToArray());
            comboBox6.DataSource = le;

            var lb = new List <Boxes> {
                new Boxes {
                    Name = "<отсутствует>", ID_Box = 0
                }
            };

            lb.AddRange(_context.Boxes.ToArray());
            comboBox7.DataSource = lb;

            if (game == null)
            {
                AddingGame                   = _context.Games.Create();
                AddingGame.Game_Type         = false;
                AddingGame.ID_Game           = (_context.Games.Any() ? _context.Games.Max(p => p.ID_Game) : 0) + 1;
                AddingGame.Game_disks        = new Collection <Game_disks>();
                AddingGame.ID_Developer      = 0;
                AddingGame.ID_Publisher      = 0;
                AddingGame.ID_RF_Distributor = 0;
                AddingGame.ID_Box            = 0;
                AddingGame.ID_Edition        = 0;
                AddingGame.ID_Ser            = 0;
                comboBox4.SelectedIndex      = 0;
                comboBox5.SelectedIndex      = 0;
                AddBut.Visible               = true;
                EditButton.Visible           = false;
                AcceptButton                 = AddBut;
            }
            else
            {
                AddingGame         = game;
                AddBut.Visible     = false;
                EditButton.Visible = true;
                if (AddingGame.Original_Name != null)
                {
                    OriginalNameEn.Checked       = true;
                    original_NameTextBox.Enabled = true;
                }
                else
                {
                    OriginalNameEn.Checked       = false;
                    original_NameTextBox.Enabled = false;
                }

                if (AddingGame.ID_Developer == null)
                {
                    AddingGame.ID_Developer = 0;
                }

                if (AddingGame.ID_Publisher == null)
                {
                    AddingGame.ID_Publisher = 0;
                }

                if (AddingGame.ID_RF_Distributor == null)
                {
                    AddingGame.ID_RF_Distributor = 0;
                }

                if (AddingGame.ID_Ser == null)
                {
                    AddingGame.ID_Ser = 0;
                }

                if (AddingGame.ID_Box == null)
                {
                    AddingGame.ID_Box = 0;
                }

                if (AddingGame.ID_Edition == null)
                {
                    AddingGame.ID_Edition = 0;
                }


                comboBox4.SelectedIndex = Decimal.ToInt32(AddingGame.Localisation_Type ?? 0);
                comboBox5.SelectedIndex = Decimal.ToInt32(AddingGame.Status_complite);


                for (var i = 0; i < PlatformsList.Items.Count; i++)
                {
                    if (AddingGame.Platforms.Any(p => p.ID_Platform == ((Platforms)PlatformsList.Items[i]).ID_Platform))
                    {
                        PlatformsList.SetItemChecked(i, true);
                    }
                }

                for (var i = 0; i < GenresList.Items.Count; i++)
                {
                    if (AddingGame.Genres.Any(p => p.ID_Genre == ((Genres)GenresList.Items[i]).ID_Genre))
                    {
                        GenresList.SetItemChecked(i, true);
                    }
                }

                for (var i = 0; i < OnlineProtectionsList.Items.Count; i++)
                {
                    if (AddingGame.Online_protections.Any(p => p.ID_Protect == ((Online_protections)OnlineProtectionsList.Items[i]).ID_Protect))
                    {
                        OnlineProtectionsList.SetItemChecked(i, true);
                    }
                }

                if (AddingGame.Poster != null)
                {
                    var stream = new MemoryStream(AddingGame.Poster);
                    posterPictureBox.Image = Image.FromStream(stream);
                    label13.Visible        = false;
                }
                else
                {
                    posterPictureBox.Image = null;
                }
                button1.Enabled  = false;
                button2.Enabled  = false;
                button3.Enabled  = false;
                button4.Enabled  = false;
                button5.Enabled  = false;
                button6.Enabled  = false;
                button7.Enabled  = false;
                button8.Enabled  = false;
                button9.Enabled  = false;
                button10.Enabled = false;
                AcceptButton     = EditButton;
            }
            GameDiskList.DataSource       = AddingGame.Game_disks.ToList();
            gamesBindingSource.DataSource = new[] { AddingGame };
        }