Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("GenreId,Name,Description")] Genres genres)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genres);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genres));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CriticId,Username")] Critics critics)
        {
            if (ModelState.IsValid)
            {
                _context.Add(critics);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(critics));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ContinentId,Name,Area")] Continents continents)
        {
            if (ModelState.IsValid)
            {
                _context.Add(continents);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(continents));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("PublisherId,Name,Earnings,Contacts")] Publishers publishers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(publishers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(publishers));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("DeveloperId,Name,FoundationDate,WorkersNumber,CountryId")] Developers developers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(developers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "Continent", developers.CountryId);
            return(View(developers));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("CountryId,Name,ContinentId")] Countries countries)
        {
            if (ModelState.IsValid)
            {
                _context.Add(countries);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContinentId"] = new SelectList(_context.Continents, "ContinentId", "Name", countries.ContinentId);
            return(View(countries));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("RatingId,CriticId,GameId,Mark")] Ratings ratings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ratings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CriticId"] = new SelectList(_context.Critics, "CriticId", "Username", ratings.CriticId);
            ViewData["GameId"]   = new SelectList(_context.Games, "GameId", "Name", ratings.GameId);
            return(View(ratings));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("PublicationId,GameId,PublisherId")] Publications publications)
        {
            if (ModelState.IsValid)
            {
                _context.Add(publications);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"]      = new SelectList(_context.Games, "GameId", "Name", publications.GameId);
            ViewData["PublisherId"] = new SelectList(_context.Publishers, "PublisherId", "Contacts", publications.PublisherId);
            return(View(publications));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("GameId,Name,DeveloperId,GenreId,Budget")] Games games)
        {
            if (ModelState.IsValid)
            {
                _context.Add(games);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DeveloperId"] = new SelectList(_context.Developers, "DeveloperId", "Name", games.DeveloperId);
            ViewData["GenreId"]     = new SelectList(_context.Genres, "GenreId", "Description", games.GenreId);
            return(View(games));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("PublisherId,Name,Earnings,Contacts")] Publishers publishers)
        {
            bool duplicate = await _context.Publishers.AnyAsync(l => l.Name.Equals(publishers.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Введене видавництво вже додане");
            }
            if (ModelState.IsValid)
            {
                _context.Add(publishers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(publishers));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("ContinentId,Name,Area")] Continents continents)
        {
            bool duplicate = await _context.Continents.AnyAsync(l => l.Name.Equals(continents.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Такий континент вже доданий");
            }
            if (ModelState.IsValid)
            {
                _context.Add(continents);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(continents));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("GenreId,Name,Description")] Genres genres)
        {
            bool duplicate = await _context.Genres.AnyAsync(l => l.Name.Equals(genres.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Такий жанр вже доданий");
            }
            if (ModelState.IsValid)
            {
                _context.Add(genres);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genres));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Create([Bind("CriticId,Username,Description")] Critics critics)
        {
            bool duplicate = await _context.Critics.AnyAsync(l => l.Username.Equals(critics.Username));

            if (duplicate)
            {
                ModelState.AddModelError("Username", "Критик с таким ім'ям вже доданий");
            }
            if (ModelState.IsValid)
            {
                _context.Add(critics);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(critics));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("DeveloperId,Name,FoundationDate,WorkersNumber,CountryId")] Developers developers)
        {
            bool duplicate = await _context.Developers.AnyAsync(l => l.Name.Equals(developers.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Такий розробник вже існує");
            }
            if (ModelState.IsValid)
            {
                _context.Add(developers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "Name", developers.CountryId);
            return(View(developers));
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("CountryId,Name,ContinentId")] Countries countries)
        {
            bool duplicate = await _context.Countries.AnyAsync(l => l.Name.Equals(countries.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Така країна вже додана");
            }
            if (ModelState.IsValid)
            {
                _context.Add(countries);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContinentId"] = new SelectList(_context.Continents, "ContinentId", "Name", countries.ContinentId);
            return(View(countries));
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("GameId,Name,DeveloperId,GenreId,Budget")] Games games)
        {
            bool duplicate = await _context.Games.AnyAsync(l => l.Name.Equals(games.Name));

            if (duplicate)
            {
                ModelState.AddModelError("Name", "Така гра вже додана");
            }
            if (ModelState.IsValid)
            {
                _context.Add(games);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DeveloperId"] = new SelectList(_context.Developers, "DeveloperId", "Name", games.DeveloperId);
            ViewData["GenreId"]     = new SelectList(_context.Genres, "GenreId", "Name", games.GenreId);
            return(View(games));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Create([Bind("RatingId,CriticId,GameId,Mark")] Ratings ratings)
        {
            bool duplicate = await _context.Ratings.AnyAsync(l => l.CriticId.Equals(ratings.CriticId) && l.GameId.Equals(ratings.GameId));

            if (duplicate)
            {
                ModelState.AddModelError("", "Цей критик вже оцінив цю гру");
            }
            if (ModelState.IsValid)
            {
                _context.Add(ratings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CriticId"] = new SelectList(_context.Critics, "CriticId", "Username", ratings.CriticId);
            ViewData["GameId"]   = new SelectList(_context.Games, "GameId", "Name", ratings.GameId);
            return(View(ratings));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Create([Bind("PublicationId,GameId,PublisherId")] Publications publications)
        {
            bool duplicate = await _context.Publications.AnyAsync(l => l.GameId.Equals(publications.GameId) && l.PublisherId.Equals(publications.PublisherId));

            if (duplicate)
            {
                ModelState.AddModelError("", "Така публікація вже додана");
            }
            if (ModelState.IsValid)
            {
                _context.Add(publications);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"]      = new SelectList(_context.Games, "GameId", "Name", publications.GameId);
            ViewData["PublisherId"] = new SelectList(_context.Publishers, "PublisherId", "Name", publications.PublisherId);
            return(View(publications));
        }