Exemple #1
0
        public IActionResult AddGames(string NameOfGame, string Image, DateTime DateOfRelease, decimal Cost, int CountOfKeys, int IdDeveloper, int IdPublusher, int IdGenre)
        {
            int IdGame = 0;

            using (ShopGamesDBContext db = new ShopGamesDBContext())
            {
                if (db.Games.Count() != 0)
                {
                    IdGame = db.Games.Max(p => p.IdGame + 1);
                }

                Games game = new Games {
                    IdGame = IdGame, NameOfGame = NameOfGame, Image = Image, DateOfRelease = DateOfRelease, Cost = Cost, CountOfKeys = CountOfKeys, IdDeveloper = IdDeveloper, IdPublisher = 0, IdGenre = 0
                };
                // Добавление
                Console.WriteLine("Запись '" + IdGame + " " + NameOfGame + " " + Image + " " + DateOfRelease + " " + Cost + " " + CountOfKeys + " " + IdDeveloper + "' была успешно добавлена!");
                db.Games.Add(game);
                db.SaveChanges();
            }


            ViewData["MessageAddGames"] = "Запись '" + IdGame + " " + NameOfGame + " " + Image + " " + DateOfRelease + " " + Cost + " " + CountOfKeys + " " + IdDeveloper + "' была успешно добавлена!";

            return(View(db.Developer.ToList()));
        }
Exemple #2
0
        public IActionResult AddDeveloper(string NameOfDeveloper, string LinkToTheWebSite)
        {
            int IdDeveloper = 0;

            using (ShopGamesDBContext db = new ShopGamesDBContext())
            {
                IdDeveloper = db.Developer.Max(p => p.IdDeveloper + 1);
                Developer dev = new Developer {
                    IdDeveloper = IdDeveloper, NameOfDeveloper = NameOfDeveloper, LinkToTheWebSite = LinkToTheWebSite
                };
                // Добавление
                db.Developer.Add(dev);
                db.SaveChanges();
            }


            ViewData["Message"] = "Запись '" + IdDeveloper + " " + NameOfDeveloper + " " + LinkToTheWebSite + "' была успешно добавлена!";

            return(View());
        }