Ejemplo n.º 1
0
        public async Task <IActionResult> PutESRB(int id, ESRB eSRB)
        {
            if (id != eSRB.ESRBId)
            {
                return(BadRequest());
            }

            _context.Entry(eSRB).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ESRBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutSeries(int id, Series series)
        {
            if (id != series.SeriesId)
            {
                return(BadRequest());
            }

            _context.Entry(series).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SeriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutDeveloper(int id, Developer developer)
        {
            if (id != developer.DeveloperId)
            {
                return(BadRequest());
            }

            _context.Entry(developer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeveloperExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutGenre(int id, Genre genre)
        {
            if (id != genre.Id)
            {
                return(BadRequest());
            }

            _context.Entry(genre).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GenreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("CityId,Name")] City city)
        {
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(city));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("PlayerId,FullName")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("TeamId,Name,CityId")] Team team)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.Cities, "CityId", "Name", team.CityId);
            return(View(team));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create(int CityId, [Bind("StadiumId,Name,CityId")] Stadium stadium)
        {
            stadium.CityId = CityId;
            if (ModelState.IsValid)
            {
                _context.Add(stadium);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Stadia", new { id = CityId, name = _context.Cities.Where(c => c.CityId == CityId).FirstOrDefault().Name }));
            }
            return(RedirectToAction("Index", "Stadia", new { id = CityId, name = _context.Cities.Where(c => c.CityId == CityId).FirstOrDefault().Name }));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("RefereeId,FullName,BirthDate")] Referee referee)
        {
            if (referee.BirthDate < new DateTime(1950, 12, 1))
            {
                ModelState.AddModelError("BirthDate", "Дата народження повина бути більша за 01.12.1950");
            }
            if (ModelState.IsValid)
            {
                _context.Add(referee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(referee));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("TournamentId,Name,Prize,StartDate,EndDate,Info")] Tournament tournament)
        {
            if (tournament.StartDate > tournament.EndDate)
            {
                ModelState.AddModelError("StartDate", "Невірний часовий проміжок");
            }
            if (tournament.Prize > 1000000000 || tournament.Prize < 0)
            {
                ModelState.AddModelError("Prize", "Сума повинна бути менше одного мільярда, і більше нуля");
            }
            if (ModelState.IsValid)
            {
                _context.Add(tournament);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournament));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create(int playerId, [Bind("CareerId,TeamId,PlayerId,StartDate,EndDate,PositionId")] Career career)
        {
            career.PlayerId = playerId;
            if (career.EndDate != null && career.StartDate > career.EndDate)
            {
                ModelState.AddModelError("StartDate", "Невірний часовий проміжок");
            }
            if (ModelState.IsValid)
            {
                _context.Add(career);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Careers", new { id = playerId, name = _context.Players.Where(c => c.PlayerId == playerId).FirstOrDefault().FullName }));
            }
            //ViewData["PlayerId"] = new SelectList(_context.Players, "PlayerId", "FullName", career.PlayerId);
            //ViewData["PositionId"] = new SelectList(_context.Positions, "PositionId", "Name", career.PositionId);
            //ViewData["TeamId"] = new SelectList(_context.Teams, "TeamId", "Name", career.TeamId);
            //return View(career);
            return(RedirectToAction("Index", "Careers", new { id = playerId, name = _context.Players.Where(a => a.PlayerId == playerId).FirstOrDefault().FullName }));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("GameId,StartTime,StadiumId,TournamentId,TeamId,TeamId2,RefereeId")] Game game)
        {
            if (game.TeamId == game.TeamId2)
            {
                ModelState.AddModelError("TeamId", "Помилкова пара команд");
            }
            if (game.StartTime < new DateTime(1970, 12, 1))
            {
                ModelState.AddModelError("StartTime", "Час доступний 1970 р.н.е. і далі");
            }
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RefereeId"]    = new SelectList(_context.Referees, "RefereeId", "FullName", game.RefereeId);
            ViewData["StadiumId"]    = new SelectList(_context.Stadiums, "StadiumId", "Name", game.StadiumId);
            ViewData["TeamId"]       = new SelectList(_context.Teams, "TeamId", "Name", game.TeamId);
            ViewData["TeamId2"]      = new SelectList(_context.Teams, "TeamId", "Name", game.TeamId2);
            ViewData["TournamentId"] = new SelectList(_context.Tournaments, "TournamentId", "Name", game.TournamentId);
            return(View(game));
        }