public ActionResult Accessories()
        {
            int PracticeID = Convert.ToInt32(Session["sespracticeid"]);
            IEnumerable<EquipmentAccessories> model;
            var EquipID = 0;
            if (Session["EQUIPID"] != null)
            {
                EquipID = Convert.ToInt32(Session["EQUIPID"]);
                model = (from p in objDbContext.EquipmentAccessorys
                         where p.StatusID == 1 && p.equip.PracticeID == PracticeID && p.EquipID == EquipID
                         select p).ToList();
                if (EquipID == 4)
                    model = (from p in objDbContext.EquipmentAccessorys
                             where p.StatusID == 1 && p.equip.PracticeID == PracticeID
                             select p).ToList();
            }
            else
            {
                model = (from p in objDbContext.EquipmentAccessorys
                         where p.StatusID == 1 && p.equip.PracticeID == PracticeID
                         select p).ToList();
            }

            var objEquip1 = (from v in objDbContext.Equipments
                            where v.StatusID == 1 && v.PracticeID == PracticeID
                            select v).ToList();
            ViewBag.EquipID = new SelectList(objEquip1, "EquipID", "Equip_Name", objDbContext.Equipments.First());
            Equipment eq = new Equipment();
            eq.EquipID = 4;
            eq.Equip_Name = "Select All";
            var objEquip = (from v in objDbContext.Equipments
                            where v.StatusID == 1 && v.PracticeID == PracticeID
                            select v).ToList();
            //ViewBag.EquipID = new SelectList(objEquip, "EquipID", "Equip_Name", objDbContext.Equipments.First());
            objEquip.Insert(0, eq);
            if (Session["EQUIPID"] == null)
            ViewBag.EquipID1 = new SelectList(objEquip, "EquipID", "Equip_Name", objDbContext.Equipments.First());
            else
             ViewBag.EquipID1 = new SelectList(objEquip, "EquipID", "Equip_Name", EquipID);

            return View(model);
        }
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 public JsonResult GetPracticeEquipments(Equipment objEquip)
 {
     var objParcticeEquipments = (from p in objDBContext.Equipments
                                  where p.PracticeID == objEquip.PracticeID
                                  select p).ToList();
     return Json(objParcticeEquipments, JsonRequestBehavior.AllowGet);
 }
        public JsonResult GetEquipmentAccessories(Equipment objEquip)
        {
            var objEquipAccessories = (from p in objDBContext.vwEquipmentAccessoriesList
                                       where p.EquipID == objEquip.EquipID
                                       select p).ToList();

            return Json(objEquipAccessories,JsonRequestBehavior.AllowGet);
        }
 public ActionResult CreateEquipent(Equipment objEquip)
 {
     Equipment objNewEquip = new Equipment();
     objNewEquip.Equip_Name = objEquip.Equip_Name;
     objNewEquip.Manufacturer = objEquip.Manufacturer;
     objNewEquip.Model = objEquip.Model;
     objNewEquip.Quantity = objEquip.Quantity;
     objNewEquip.QuantityonHand = objEquip.QuantityonHand;
     objNewEquip.PracticeID = Convert.ToInt32(Session["sespracticeid"]);
     objNewEquip.StatusID = 1;
     objDbContext.Equipments.Add(objNewEquip);
     objDbContext.SaveChanges();
     return Json(new { data = "Success" });
 }
 public ActionResult GetEquipentData(Equipment objEquip)
 {
     var EquipmentsList = (from p in objDbContext.Equipments
                           where p.EquipID == objEquip.EquipID
                           select p).ToList();
     return Json(EquipmentsList);
 }
        public ActionResult EditEquipent(Equipment objEquip)
        {
            Equipment EquipmentsList = (from p in objDbContext.Equipments
                                        where p.EquipID == objEquip.EquipID
                                        select p).FirstOrDefault();

            EquipmentsList.Equip_Name = objEquip.Equip_Name;
            EquipmentsList.Manufacturer = objEquip.Manufacturer;
            EquipmentsList.Model = objEquip.Model;
            EquipmentsList.Quantity = objEquip.Quantity;
            EquipmentsList.QuantityonHand = objEquip.QuantityonHand;

            objDbContext.SaveChanges();
            return Json(new { data = "Success" });
        }
        public ActionResult DeleteEquipent(Equipment objEquip)
        {
            Equipment EquipmentsList = (from p in objDbContext.Equipments
                                        where p.EquipID == objEquip.EquipID
                                        select p).FirstOrDefault();
            EquipmentsList.StatusID = 2;

               IEnumerable<EquipmentAccessories> equipAcc = (from v in objDbContext.EquipmentAccessorys
                                            where v.EquipID == objEquip.EquipID
                                            select v).ToList();
               foreach (var acc in equipAcc)
               {
               acc.StatusID = 2;
               }
               objDbContext.SaveChanges();
            return Json(new { data = "Success" });
        }