// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Players).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayersExists(Players.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var GameToUpdate = await _context.Game .Include(i => i.Players) .Include(i => i.GameCategories) .ThenInclude(i => i.Category) .FirstOrDefaultAsync(s => s.ID == id); if (GameToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Game>( GameToUpdate, "Game", i => i.Name, i => i.GameGenre, i => i.Price, i => i.PublishingDate, i => i.Players)) { UpdateGameCategories(_context, selectedCategories, GameToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } //Apelam UpdateAlbumCategories pentru a aplica informatiile din checkboxuri la entitatea Albums care //este editata UpdateGameCategories(_context, selectedCategories, GameToUpdate); PopulateAssignedCategoryData(_context, GameToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newGame = new Game(); if (selectedCategories != null) { newGame.GameCategories = new List <GameCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new GameCategory { CategoryID = int.Parse(cat) }; newGame.GameCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Game>( newGame, "Game", i => i.Name, i => i.GameGenre, i => i.Price, i => i.PublishingDate, i => i.PlayersID)) { _context.Game.Add(newGame); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newGame); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Category.Add(Category); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Players = await _context.Players.FindAsync(id); if (Players != null) { _context.Players.Remove(Players); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Category = await _context.Category.FindAsync(id); if (Category != null) { _context.Category.Remove(Category); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Game = await _context.Game.FindAsync(id); if (Game != null) { _context.Game.Remove(Game); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }