public async Task <IActionResult> Create([Bind("Id,Name,Info")] Distributors distributors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(distributors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(distributors));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Info")] Genres genres)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genres);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["GenreId"] = new SelectList(_context.Genres, "Id", "Name", genres.Id);
            return(View(genres));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create(int SubsidiariesId, [Bind("Id,GameId")] GamesDevelopers gamesDevelopers)
        {
            gamesDevelopers.SubsidiariesId = SubsidiariesId;
            if (ModelState.IsValid)
            {
                _context.Add(gamesDevelopers);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "GamesDevelopers", new { id = SubsidiariesId, name = _context.Subsidiaries.Where(s => s.Id == SubsidiariesId).FirstOrDefault().Name }));
            }
            //ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Engine", gamesDevelopers.GameId);
            //ViewData["SubsidiariesId"] = new SelectList(_context.Subsidiaries, "Id", "Location", gamesDevelopers.SubsidiariesId);
            return(RedirectToAction("Index", "GamesDevelopers", new { id = SubsidiariesId, name = _context.Subsidiaries.Where(s => s.Id == SubsidiariesId).FirstOrDefault().Name }));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create(int GameId, [Bind("Id,PlatformId")] GamesPlatforms gamesPlatforms)
        {
            gamesPlatforms.GameId = GameId;
            if (ModelState.IsValid)
            {
                _context.Add(gamesPlatforms);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "GamesPlatforms", new { id = GameId, name = _context.ComputerGames.Where(c => c.Id == GameId).FirstOrDefault().Name }));
            }
            //ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Engine", gamesPlatforms.GameId);
            //ViewData["PlatformId"] = new SelectList(_context.Platforms, "Id", "Info", gamesPlatforms.PlatformId);
            //return View(gamesPlatforms);
            return(RedirectToAction("Index", "GamesPlatforms", new { id = GameId, name = _context.ComputerGames.Where(c => c.Id == GameId).FirstOrDefault().Name }));
        }
        public async Task <IActionResult> Create(int CompanyId, [Bind("Id,Name,Location,CompanyId,ManagerFullName")] Subsidiaries subsidiaries)
        {
            subsidiaries.CompanyId = CompanyId;

            if (ModelState.IsValid)
            {
                _context.Add(subsidiaries);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Subsidiaries", new { id = CompanyId, name = _context.GameDevCompanies.Where(c => c.Id == CompanyId).FirstOrDefault().Name }));
            }
            //ViewData["CompanyId"] = new SelectList(_context.GameDevCompanies, "Id", "DirectorFullName", subsidiaries.CompanyId);
            //return View(subsidiaries);
            return(RedirectToAction("Index", "Subsidiaries", new { id = CompanyId, name = _context.GameDevCompanies.Where(c => c.Id == CompanyId).FirstOrDefault().Name }));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Location,DirectorFullName")] GameDevCompanies gameDevCompanies)
        {
            GameDevCompanies existingCompany = await _context.GameDevCompanies.FirstOrDefaultAsync(
                c => c.Name == gameDevCompanies.Name && c.Location == gameDevCompanies.Location);

            if (existingCompany != null)
            {
                ModelState.AddModelError(string.Empty, "This company already exists.");
            }

            else if (ModelState.IsValid)
            {
                _context.Add(gameDevCompanies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gameDevCompanies));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,Name,Budget,Engine")] ComputerGames computerGames)
        {
            ComputerGames existingGame = await _context.ComputerGames.FirstOrDefaultAsync(
                g => g.Name == computerGames.Name);

            if (existingGame != null)
            {
                ModelState.AddModelError(string.Empty, "This game already exists.");
            }

            else if (ModelState.IsValid)
            {
                _context.Add(computerGames);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(computerGames));
        }