public async Task <IActionResult> DeleteConfirmed(int id) { await WeaponDb.Delete(id, _context); TempData["Message"] = "Weapon deleted successfully"; return(RedirectToAction(nameof(ShowAll))); }
public Enchantment GetEnchantmentById(int Id) { using (WeaponDb db = new WeaponDb()) { var enchantmentItem = db.Enchantments.Where(e => e.EnchantmentId == Id).FirstOrDefault(); return(enchantmentItem); } }
public ICollection <Enchantment> GetAllEnchantmentByElement(string Element) { using (WeaponDb db = new WeaponDb()) { var EnchantmentList = db.Enchantments.Where(e => e.Element == Element).ToList <Enchantment>(); return(EnchantmentList); } }
// tam adre wey , ya me acorde public ICollection <Enchantment> GetAllEnchantmentByLevel(int Level) { using (WeaponDb db = new WeaponDb()) { var EnchantmentList = db.Enchantments.Where(e => e.Level == Level).ToList <Enchantment>(); return(EnchantmentList); } }
public ICollection <Axe> GetAllAxes() { using (WeaponDb db = new WeaponDb()) { var axes = db.Axes.Include(a => a.Enchantment); return(axes.ToList()); } }
public async Task <IActionResult> Delete(int id) { Weapon w = await WeaponDb.GetWeaponById(id, _context); if (w == null) { return(NotFound()); } return(View(w)); }
public async Task <IActionResult> Edit(Weapon w) { if (ModelState.IsValid) { await WeaponDb.Edit(w, _context); TempData["Message"] = w.WeaponName + " updated successfully"; return(RedirectToAction(nameof(ShowAll))); } return(View(w)); }
public ICollection <Axe> GetAllAxes() { using (WeaponDb db = new WeaponDb()) { var axes = db.Axes.ToList <Axe>(); foreach (var axe in axes) { axe.Enchantment = enchantmentRepository.GetEnchantmentById(axe.EnchantmentId); } return(axes); } }
public bool AddAxe(Axe AxeItem) { if (AxeItem != null) { using (WeaponDb db = new WeaponDb()) { db.Axes.Add(AxeItem); db.SaveChanges(); return(true); } } return(false); }
public bool AddAxe(AxeDTO AxeItem) { if (AxeItem != null) { Axe newAxe = ConverterDTOToModel.ConvertAxeDTOToAxeModel(AxeItem); using (WeaponDb db = new WeaponDb()) { db.Axes.Add(newAxe); db.SaveChanges(); return(true); } } return(false); }
public async Task <IActionResult> Index() { WeaponStatViewModel model = new WeaponStatViewModel(); List <Stat> statResult = (from s in _context.Stats select s).ToList(); // Get stats from DB model.WeaponStats = statResult; // all weapon stats model.AllWeapons = await WeaponDb.GetAllWeapons(_context); ViewData["userMsg"] = "Apply button applies both weapons and all selected stats."; return(View(model)); }
public async Task <IActionResult> Index(WeaponStatViewModel model, IFormCollection form) { List <Stat> statResult = (from s in _context.Stats select s).ToList(); // Get stats from DB model.WeaponStats = statResult; // all weapon stats model.AllWeapons = await WeaponDb.GetAllWeapons(_context); // Gets both weapons from Index View string firstWeap = Request.Form["firstWeapon"]; string secondWeap = Request.Form["secondWeapon"]; // Gets all selected stats from Index View model.SelectedStats = await getSelectedStats(form); // Checks if weapons are selected if (firstWeap != null && firstWeap != "" && secondWeap != null && secondWeap != "" && firstWeap != secondWeap) { // Adds selected weapons to ViewModel int firstWeapSelected = int.Parse(firstWeap); model.ChosenWeapon1 = await WeaponDb.GetWeaponById(firstWeapSelected, _context); int secondWeapSelected = int.Parse(secondWeap); model.ChosenWeapon2 = await WeaponDb.GetWeaponById(secondWeapSelected, _context); // If stats are selected add them to weapon stats if (model.SelectedStats.Count() != 0) { model.ChosenWeapon1 = addSelectedStats(model.SelectedStats, model.ChosenWeapon1); model.ChosenWeapon2 = addSelectedStats(model.SelectedStats, model.ChosenWeapon2); } // ViewData["userMsg"] = model.ChosenWeapon1.WeaponName + " and " + model.ChosenWeapon2.WeaponName; } else { ViewData["userMsg"] = "Please select two different weapons before applying"; } return(View(model)); }
public async Task <IActionResult> ShowAll() { List <Weapon> weapons = await WeaponDb.GetAllWeapons(_context); return(View(weapons)); }