// 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 roomNumber, int dungeonID, int enemyID) { var eirToUpdate = await _context.EnemyInRooms.FindAsync(dungeonID, roomNumber, enemyID); if (eirToUpdate == null) { return(NotFound()); } // if we've changed the enemyID (which is part of the key) // then we actually need to delete this EIR and make a new one if (enemyID != EnemyInRoom.EnemyID) { // delete EIR and make new one try { _context.EnemyInRooms.Remove(eirToUpdate); await _context.SaveChangesAsync(); var emptyEIR = new EnemyInRoom(); emptyEIR.DungeonID = dungeonID; emptyEIR.RoomNum = roomNumber; if (await TryUpdateModelAsync <EnemyInRoom>( emptyEIR, "enemyinroom", d => d.EnemyID, d => d.Count, d => d.Name, d => d.Description)) { _context.EnemyInRooms.Add(emptyEIR); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } return(Page()); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Edit", new { roomNumber, dungeonID, enemyID, saveChangesError = true })); } } // otherwise just update if (await TryUpdateModelAsync <EnemyInRoom>( eirToUpdate, "enemyinroom", d => d.EnemyID, d => d.Count, d => d.Name, d => d.Description)) { await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } 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(int lootSetID, int lootID) { var lisToUpdate = await _context.LootInSets.FindAsync(lootSetID, lootID); if (lisToUpdate == null) { return(NotFound()); } // if we've changed the lootID (which is part of the key) // then we actually need to delete this LIS and make a new one if (lootID != LootInSet.LootID) { // delete LIS and make new one try { _context.LootInSets.Remove(lisToUpdate); await _context.SaveChangesAsync(); var emptyLIS = new LootInSet(); emptyLIS.LootSetID = lootSetID; if (await TryUpdateModelAsync <LootInSet>( emptyLIS, "lootinset", d => d.LootID, d => d.Count, d => d.Name, d => d.Description)) { _context.LootInSets.Add(emptyLIS); await _context.SaveChangesAsync(); return(RedirectToPage("/LootSets/Details", new { id = lootSetID })); } return(Page()); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Edit", new { lootSetID, lootID, saveChangesError = true })); } } // otherwise just update if (await TryUpdateModelAsync <LootInSet>( lisToUpdate, "lootinset", d => d.LootID, d => d.Count, d => d.Name, d => d.Description)) { await _context.SaveChangesAsync(); return(RedirectToPage("/LootSets/Details", new { id = lootSetID })); } 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(int lootID, int mediaID) { var lmToUpdate = await _context.LootMedias.FindAsync(lootID, mediaID); if (lmToUpdate == null) { return(NotFound()); } // if we've changed the MediaID (which is part of the key) // then we actually need to delete this EM and make a new one if (mediaID != LootMedia.MediaID) { // delete EM and make new one try { _context.LootMedias.Remove(lmToUpdate); await _context.SaveChangesAsync(); var emptyLM = new LootMedia(); emptyLM.LootID = lootID; if (await TryUpdateModelAsync <LootMedia>( emptyLM, "lootmedia", d => d.MediaID, d => d.MediaLabel)) { _context.LootMedias.Add(emptyLM); await _context.SaveChangesAsync(); return(RedirectToPage("/Loots/Details", new { id = lootID })); } return(Page()); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Edit", new { lootID, mediaID, saveChangesError = true })); } } // otherwise just update if (await TryUpdateModelAsync <LootMedia>( lmToUpdate, "lootmedia", d => d.MediaID, d => d.MediaLabel)) { await _context.SaveChangesAsync(); return(RedirectToPage("/Loots/Details", new { id = lootID })); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?layoutID, int?mediaID) { if (layoutID == null || mediaID == null) { return(NotFound()); } var lm = await _context.LayoutMedias.FindAsync(layoutID, mediaID); if (lm == null) { return(NotFound()); } try { _context.LayoutMedias.Remove(lm); await _context.SaveChangesAsync(); return(RedirectToPage("/Layouts/Details", new { id = layoutID })); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Delete", new { layoutID, mediaID, saveChangesError = true })); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var enemy = await _context.Enemies.FindAsync(id); if (enemy == null) { return(NotFound()); } try { _context.Enemies.Remove(enemy); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }
public async Task <IActionResult> OnPostAsync(int?roomNumber, int?dungeonID) { if (roomNumber == null || dungeonID == null) { return(NotFound()); } var room = await _context.Rooms.FindAsync(roomNumber, dungeonID); if (room == null) { return(NotFound()); } try { _context.Rooms.Remove(room); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Delete", new { roomNumber, dungeonID, saveChangesError = true })); } }
public async Task <IActionResult> OnPostAsync(int?enemySetID, int?enemyID) { if (enemySetID == null || enemyID == null) { return(NotFound()); } var eis = await _context.EnemyInSets.FindAsync(enemySetID, enemyID); if (eis == null) { return(NotFound()); } try { _context.EnemyInSets.Remove(eis); await _context.SaveChangesAsync(); return(RedirectToPage("/EnemySets/Details", new { id = enemySetID })); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Delete", new { enemySetID, enemyID, saveChangesError = true })); } }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int roomNumber, int dungeonID) { AddedMessage = ""; // get enemy ids which are already associated with this room var taken_enemy_ids = await _context.EnemyInRooms .Where(eir => (eir.DungeonID == dungeonID && eir.RoomNum == roomNumber)) .Select(eir => eir.EnemyID) .ToListAsync(); // get enemyInSets which are associated with the chosen set but not with an enemy in the previous list var eiss = await _context.EnemyInSets .Where(eis => (eis.EnemySetID == EnemySetID && !taken_enemy_ids.Contains(eis.EnemyID))) .Include(eis => eis.Enemy) .ToListAsync(); // add set // foreach eis // create a copy eir // for each enemy in the set foreach (EnemyInSet eis in eiss) { // make a new EIR EnemyInRoom emptyEIR = new EnemyInRoom(); // link EIR to proper room emptyEIR.DungeonID = dungeonID; emptyEIR.RoomNum = roomNumber; // copy data from eis emptyEIR.EnemyID = eis.EnemyID; emptyEIR.Count = eis.Count; emptyEIR.Name = eis.Name; emptyEIR.Description = eis.Description; // add EIR to database _context.EnemyInRooms.Add(emptyEIR); await _context.SaveChangesAsync(); AddedMessage += $"Added {(eis.Name == null ? eis.Enemy.Name : eis.Name)} x{eis.Count}\n"; } // remove trailing newline AddedMessage.Trim('\n'); // return to adding page return(RedirectToAction("./AddEnemySet", new { roomNumber, dungeonID, saveChangesError = true })); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int roomNumber, int dungeonID) { AddedMessage = ""; // get enemy ids which are already associated with this room var taken_enemy_ids = await _context.LootInRooms .Where(lir => (lir.DungeonID == dungeonID && lir.RoomNum == roomNumber)) .Select(lir => lir.LootID) .ToListAsync(); // get enemyInSets which are associated with the chosen set but not with an enemy in the previous list var liss = await _context.LootInSets .Where(lis => (lis.LootSetID == LootSetID && !taken_enemy_ids.Contains(lis.LootID))) .Include(lis => lis.Loot) .ToListAsync(); // add set // foreach lis // create a copy lir // for each enemy in the set foreach (LootInSet lis in liss) { // make a new LIR LootInRoom emptyLIR = new LootInRoom(); // link LIR to proper room emptyLIR.DungeonID = dungeonID; emptyLIR.RoomNum = roomNumber; // copy data from lis emptyLIR.LootID = lis.LootID; emptyLIR.Count = lis.Count; emptyLIR.Name = lis.Name; emptyLIR.Description = lis.Description; // add LIR to database _context.LootInRooms.Add(emptyLIR); await _context.SaveChangesAsync(); AddedMessage += $"Added {(lis.Name == null ? lis.Loot.Name : lis.Name)} x{lis.Count}\n"; } // remove trailing newline AddedMessage.Trim('\n'); // return to adding page return(RedirectToAction("./AddLootSet", new { roomNumber, dungeonID, addedMessage = AddedMessage })); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { var emptyEnemy = new Enemy(); if (await TryUpdateModelAsync <Enemy>( emptyEnemy, "enemy", // Prefix for form value. d => d.Name, d => d.Description, d => d.CR)) { _context.Enemies.Add(emptyEnemy); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { var emptyLootSet = new LootSet(); if (await TryUpdateModelAsync <LootSet>( emptyLootSet, "lootset", // Prefix for form value. d => d.Name, d => d.Description)) { _context.LootSets.Add(emptyLootSet); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostUploadAsync() { // Perform an initial check to catch FileUpload class // attribute violations. if (!ModelState.IsValid) { ErrorMessage = "Please correct the form."; return(Page()); } var formFileContent = await FileHelpers.ProcessFormFile <IFormFile>( FileUpload, ModelState, _permittedExtensions, _fileSizeLimit); // Perform a second check to catch ProcessFormFile method // violations. If any validation check fails, return to the // page. if (!ModelState.IsValid) { ErrorMessage = "Please correct the form."; return(Page()); } var emptyMedia = new Media(); // emptyEnemy.Created = DateTime.UtcNow; if (await TryUpdateModelAsync <Media>( emptyMedia, "media", // Prefix for form value. d => d.Name, d => d.Description)) { emptyMedia.File = formFileContent; _context.Medias.Add(emptyMedia); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { var emptyDungeon = new Dungeon(); // emptyDungeon.Created = DateTime.UtcNow; if (await TryUpdateModelAsync <Dungeon>( emptyDungeon, "dungeon", // Prefix for form value. d => d.Name, d => d.Description)) { _context.Dungeons.Add(emptyDungeon); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int lootSetID) { var emptyLIS = new LootInSet(); emptyLIS.LootSetID = lootSetID; if (await TryUpdateModelAsync <LootInSet>( emptyLIS, "lootinset", // Prefix for form value. d => d.LootID, d => d.Count, d => d.Name, d => d.Description)) { _context.LootInSets.Add(emptyLIS); await _context.SaveChangesAsync(); return(RedirectToPage("/LootSets/Details", new { id = lootSetID })); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int enemyID) { var emptyEM = new EnemyMedia(); emptyEM.EnemyID = enemyID; if (await TryUpdateModelAsync <EnemyMedia>( emptyEM, "enemymedia", // Prefix for form value. d => d.MediaID, d => d.MediaLabel)) { _context.EnemyMedias.Add(emptyEM); await _context.SaveChangesAsync(); return(RedirectToPage("/Enemies/Details", new { id = enemyID })); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { var emptyLayout = new Layout(); // emptyEnemy.Created = DateTime.UtcNow; if (await TryUpdateModelAsync <Layout>( emptyLayout, "layout", // Prefix for form value. d => d.Name, d => d.Description)) { _context.Layouts.Add(emptyLayout); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int layoutID) { var emptyLM = new LayoutMedia(); emptyLM.LayoutID = layoutID; if (await TryUpdateModelAsync <LayoutMedia>( emptyLM, "layoutmedia", // Prefix for form value. d => d.MediaID, d => d.MediaLabel)) { _context.LayoutMedias.Add(emptyLM); await _context.SaveChangesAsync(); return(RedirectToPage("/Layouts/Details", new { id = layoutID })); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int roomNumber, int dungeonID) { var emptyRC = new RoomConnection(); emptyRC.Room1Num = roomNumber; emptyRC.DungeonID = dungeonID; if (await TryUpdateModelAsync <RoomConnection>( emptyRC, "roomconnection", // Prefix for form value. d => d.Room2Num, d => d.ConnectionPoint1, d => d.ConnectionPoint2)) { _context.RoomConnections.Add(emptyRC); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int roomNumber, int dungeonID) { var emptyLIR = new LootInRoom(); emptyLIR.RoomNum = roomNumber; emptyLIR.DungeonID = dungeonID; if (await TryUpdateModelAsync <LootInRoom>( emptyLIR, "lootinroom", // Prefix for form value. d => d.LootID, d => d.Count, d => d.Name, d => d.Description)) { _context.LootInRooms.Add(emptyLIR); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } return(Page()); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync(int roomNumber, int dungeonID) { var emptyRoom = new Room(); emptyRoom.RoomNumber = roomNumber; emptyRoom.DungeonID = dungeonID; if (await TryUpdateModelAsync <Room>( emptyRoom, "room", // Prefix for form value. d => d.Name, d => d.Description, d => d.LayoutID)) { _context.Rooms.Add(emptyRoom); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } 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(int id) { var enemyToUpdate = await _context.Enemies.FindAsync(id); if (enemyToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Enemy>( enemyToUpdate, "enemy", d => d.Name, d => d.Description, d => d.XP)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } 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(int roomNumber, int dungeonID) { var roomToUpdate = await _context.Rooms.FindAsync(roomNumber, dungeonID); if (roomToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Room>( roomToUpdate, "room", d => d.Name, d => d.Description, d => d.LayoutID)) { await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } 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(int id) { var dungeonToUpdate = await _context.Dungeons.FindAsync(id); if (dungeonToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Dungeon>( dungeonToUpdate, "dungeon", d => d.Name, d => d.Description)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } 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(int id) { var lootSetToUpdate = await _context.LootSets.FindAsync(id); if (lootSetToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <LootSet>( lootSetToUpdate, "lootset", d => d.Name, d => d.Description)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } 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(int room1Number, int room2Number, int dungeonID, bool isFirst) { var rcToUpdate = await _context.RoomConnections.FindAsync(dungeonID, room1Number, room2Number); if (rcToUpdate == null) { return(NotFound()); } // if we've changed either roomNumber (which is part of the key) // then we actually need to delete this RC and make a new one if (room1Number != RoomConnection.Room1Num || room2Number != RoomConnection.Room2Num) { // delete RC and make new one try { _context.RoomConnections.Remove(rcToUpdate); await _context.SaveChangesAsync(); var emptyRC = new RoomConnection(); emptyRC.DungeonID = dungeonID; if (isFirst) { emptyRC.Room1Num = room1Number; if (await TryUpdateModelAsync <RoomConnection>( emptyRC, "roomconnection", d => d.Room2Num, d => d.ConnectionPoint1, d => d.ConnectionPoint2)) { _context.RoomConnections.Add(emptyRC); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } } else { emptyRC.Room2Num = room2Number; if (await TryUpdateModelAsync <RoomConnection>( emptyRC, "roomconnection", d => d.Room1Num, d => d.ConnectionPoint1, d => d.ConnectionPoint2)) { _context.RoomConnections.Add(emptyRC); await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } } return(Page()); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Edit", new { room1Number, room2Number, dungeonID, isFirst, saveChangesError = true })); } } // otherwise just update if (isFirst) { if (await TryUpdateModelAsync <RoomConnection>( rcToUpdate, "roomconnection", d => d.Room2Num, d => d.ConnectionPoint1, d => d.ConnectionPoint2)) { await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } } else { if (await TryUpdateModelAsync <RoomConnection>( rcToUpdate, "roomconnection", d => d.Room1Num, d => d.ConnectionPoint1, d => d.ConnectionPoint2)) { await _context.SaveChangesAsync(); return(RedirectToPage("/Dungeons/Details", new { id = dungeonID })); } } return(Page()); }