public List <FirearmType> RetrieveSpecificFirearmType(int userTypeID) { using (var db = new BallisticContext()) { return(db.FirearmTypes.Where(ft => ft.FirearmTypeID == userTypeID).ToList <FirearmType>()); } }
public List <Ammunition> RetrieveSpecificAmmunition(int userAmmunitionID) { using (var db = new BallisticContext()) { return(db.Ammunition.Where(a => a.AmmunitionID == userAmmunitionID).ToList <Ammunition>()); } }
public List <FirearmType> RetrieveAllFirearmType() { using (var db = new BallisticContext()) { return(db.FirearmTypes .ToList <FirearmType>()); } }
public List <Ammunition> RetrieveAllAmmunition() { using (var db = new BallisticContext()) { return(db.Ammunition .ToList <Ammunition>()); } }
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 AddFirearmType(string typeName) { using (var db = new BallisticContext()) { db.Add(new FirearmType { TypeName = typeName }); db.SaveChanges(); } }
public List <Firearm> RetrieveAllFirearm() { using (var db = new BallisticContext()) { return(db.Firearms .Include(a => a.Ammunition) .Include(ft => ft.FirearmType) .ToList()); } }
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 List <Firearm> RetrieveSpecificFirearm(int userFirearmID) { using (var db = new BallisticContext()) { return(db.Firearms .Include(a => a.Ammunition) .Include(ft => ft.FirearmType) .Where(f => f.FirearmID == userFirearmID) .ToList <Firearm>()); } }
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(); } } }