コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #13
0
ファイル: CriticsController.cs プロジェクト: hegla/GameLab
        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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #16
0
ファイル: GamesController.cs プロジェクト: hegla/GameLab
        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));
        }
コード例 #17
0
ファイル: RatingsController.cs プロジェクト: hegla/GameLab
        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));
        }
コード例 #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));
        }