public void UpdateWeapon() { WeaponRepository repo = new WeaponRepository(new WeaponSQLContext()); Weapon c = repo.GetById(4); c.PhysDamage += 20; int damage = c.PhysDamage; repo.Update(c); c = repo.GetById(4); Assert.AreEqual(c.PhysDamage, damage, "Weapon wasn't updated."); c.PhysDamage -= 20; repo.Update(c); }
public async Task Update(int ID, WeaponResource resource) { var entity = _mapper.Map <Weapon>(resource); // Ensure WeaponType is supplied if (entity.WeaponType == null) { throw new InvalidModelException("weapon.WeaponType", "Null"); } var weaponType = await _weaponTypeRepository.GetByWeaponType(entity.WeaponType.Color, entity.WeaponType.Arm); entity.WeaponTypeID = weaponType.ID; entity.WeaponType = null; // Ensure WeaponCost is supplied if (entity.WeaponCost == null) { throw new InvalidModelException("weapon.WeaponCost", "Null"); } // Update weapon await _weaponRepository.Update(entity); // Update weaponCost await _weaponCostRepository.Update(entity.WeaponCost); // Update WeaponEffectiveAgainst if (entity.WeaponEffectiveAgainst != null) { await _WeaponEffectiveAgainstRepository.Update(entity.WeaponEffectiveAgainst); } // Update WeaponStatChange if (entity.WeaponStatChange != null) { await _weaponStatChangeRepository.Update(entity.WeaponStatChange); } await _weaponRepository.SaveChanges(); }
public ActionResult Edit(Weapon weapon) { weaponRepository = new WeaponRepository(); weaponRepository.Update(weapon); return(RedirectToAction("Weapons")); }