Esempio n. 1
0
        public async Task <IActionResult> PutRabbitStatistic([FromRoute] int id, [FromBody] RabbitStatistic rabbitStatistic)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rabbitStatistic.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ArticleID,Date,Title,TeaserText,Image,Text,ExternalLink,ReadmoreLink")] Article article)
        {
            if (ModelState.IsValid)
            {
                _context.Add(article);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(article));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("LandID,Landenavn")] Land land)
        {
            if (ModelState.IsValid)
            {
                _context.Add(land);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(land));
        }
        public async Task <IActionResult> Create([Bind("StadionID,Navn,AttendanceCapacity")] Stadion stadion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stadion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stadion));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("LigaID,Navn,Logo,LandID")] Liga liga)
        {
            if (ModelState.IsValid)
            {
                _context.Add(liga);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LandID"] = new SelectList(_context.Land, "LandID", "Landenavn", liga.LandID);
            return(View(liga));
        }
        public async Task <IActionResult> Create([Bind("SponsorID,Title,SponsorText,Team2ID")] Sponsor sponsor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sponsor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Team2ID"] = new SelectList(_context.Team2s, "Id", "Name", sponsor.Team2ID);
            return(View(sponsor));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,Name,Address,StadionID,Seasontickets,Image,Logo,Sponsortext,LigaID")] Team2 team2)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team2);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StadionID"] = new SelectList(_context.Stadion, "StadionID", "Navn", team2.StadionID);
            ViewData["LigaID"]    = new SelectList(_context.Liga, "LigaID", "Navn", team2.LigaID);
            return(View(team2));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("Id,Date,HomeTeamId,AwayTeamId,HomeScore,GuestScore,Attendance,Tv,StadionID,LigaID,IsCorona")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AwayTeamId"] = new SelectList(_context.Team2s, "Id", "Name", game.AwayTeamId);
            ViewData["HomeTeamId"] = new SelectList(_context.Team2s, "Id", "Name", game.HomeTeamId);
            ViewData["LigaID"]     = new SelectList(_context.Liga, "LigaID", "Navn", game.LigaID);
            ViewData["StadionID"]  = new SelectList(_context.Stadion, "StadionID", "Navn", game.StadionID);
            return(View(game));
        }
Esempio n. 9
0
        public async static Task <Weapon> Add(Weapon w, StatContext context)
        {
            await context.AddAsync(w);

            await context.SaveChangesAsync();

            return(w);
        }
Esempio n. 10
0
        public async static Task <Weapon> Edit(Weapon w, StatContext context)
        {
            await context.AddAsync(w);

            context.Entry(w).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(w);
        }
Esempio n. 11
0
        private async Task <bool> SaveChangesAsync()
        {
            int n = await context.SaveChangesAsync();

            if (n != 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
        public async static Task Delete(int id, StatContext context)
        {
            Weapon w = await GetWeaponById(id, context);

            if (w != null)
            {
                await context.AddAsync(w);

                context.Entry(w).State = EntityState.Deleted;
                await context.SaveChangesAsync();
            }
        }