public void AddFirearmType(string typeName) { using (var db = new BallisticContext()) { db.Add(new FirearmType { TypeName = typeName }); db.SaveChanges(); } }
public void UpdateFirearmType(int typeID, string typeName) { using (var db = new BallisticContext()) { var SelectedFirearmType = db.FirearmTypes.Where(ft => ft.FirearmTypeID == typeID).FirstOrDefault(); SelectedFirearmType.TypeName = typeName; db.SaveChanges(); } }
public void AddAmmunition(string ammunitionName, float coefficient, float grain, float diameter) { using (var db = new BallisticContext()) { db.Add(new Ammunition { AmmunitionName = ammunitionName, Coefficient = coefficient, Grain = grain, Diameter = diameter }); db.SaveChanges(); } }
public void AddFirearm(string firearmName, int muzzleVelocity, int typeID, int ammunitionID) { using (var db = new BallisticContext()) { db.Add(new Firearm { FirearmName = firearmName, MuzzleVelocity = muzzleVelocity, FirearmTypeID = typeID, AmmunitionID = ammunitionID }); db.SaveChanges(); } }
public void UpdateAmmunition(int ammunitionID, string ammunitionName, float coefficient, float grain, float diameter) { using (var db = new BallisticContext()) { var SelectedAmmunition = db.Ammunition.Where(a => a.AmmunitionID == ammunitionID).FirstOrDefault(); SelectedAmmunition.AmmunitionName = ammunitionName; SelectedAmmunition.Coefficient = coefficient; SelectedAmmunition.Grain = grain; SelectedAmmunition.Diameter = diameter; db.SaveChanges(); } }
public void UpdateFirearm(int firearmID, string firearmName, int muzzleVelocity, int typeID, int ammunitionID) { using (var db = new BallisticContext()) { var SelectedFirearm = db.Firearms.Where(f => f.FirearmID == firearmID).FirstOrDefault(); SelectedFirearm.FirearmName = firearmName; SelectedFirearm.MuzzleVelocity = muzzleVelocity; SelectedFirearm.FirearmTypeID = typeID; SelectedFirearm.AmmunitionID = ammunitionID; db.SaveChanges(); } }
public void DeleteFirearm(int firearmID) { using (var db = new BallisticContext()) { var firearmToDelete = db.Firearms.Where(f => f.FirearmID == firearmID).FirstOrDefault(); if (firearmToDelete != null) { db.Firearms.Remove(firearmToDelete); db.SaveChanges(); } } }
public void DeleteAmmunition(int ammunitionID) { using (var db = new BallisticContext()) { var ammunitionToDelete = db.Ammunition.Where(a => a.AmmunitionID == ammunitionID).FirstOrDefault(); var firearmToCheck = db.Firearms.Where(f => f.AmmunitionID == ammunitionID).FirstOrDefault(); if (firearmToCheck == null && ammunitionToDelete != null) { db.Ammunition.Remove(ammunitionToDelete); db.SaveChanges(); } } }
public void DeleteFirearmType(int typeID) { using (var db = new BallisticContext()) { var firearmTypeToDelete = db.FirearmTypes.Where(ft => ft.FirearmTypeID == typeID).FirstOrDefault(); var firearmToCheck = db.Firearms.Where(f => f.FirearmTypeID == typeID).FirstOrDefault(); if (firearmToCheck == null && firearmTypeToDelete != null) { db.FirearmTypes.Remove(firearmTypeToDelete); db.SaveChanges(); } } }