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()); }
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)); }
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)); }
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)); }
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)); }
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)); }
public async static Task <Weapon> Add(Weapon w, StatContext context) { await context.AddAsync(w); await context.SaveChangesAsync(); return(w); }
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); }
private async Task <bool> SaveChangesAsync() { int n = await context.SaveChangesAsync(); if (n != 0) { return(true); } return(false); }
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(); } }