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>());
     }
 }
Esempio n. 5
0
        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();
            }
        }
Esempio n. 6
0
 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());
     }
 }
Esempio n. 8
0
 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();
     }
 }
Esempio n. 9
0
 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>());
     }
 }
Esempio n. 11
0
        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();
            }
        }
Esempio n. 12
0
        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();
            }
        }
Esempio n. 13
0
        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();
                }
            }
        }
Esempio n. 14
0
        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();
                }
            }
        }
Esempio n. 15
0
        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();
                }
            }
        }