public ActionResult DelData(AccessPassModel model)
        {
            try
            {
                int mm  = model.month;
                int yy  = model.year;
                int cid = 0;
                if (model.CompID != null && model.CompID != 0)
                {
                    cid = Convert.ToInt32(model.CompID);
                }
                AccessPassService      objService = new AccessPassService();
                AccessPassModel        objModel   = new AccessPassModel();
                List <AccessPassModel> objList    = new List <AccessPassModel>();

                objList         = objService.getAPDataByMMYY(cid, mm, yy);
                objModel.ListAP = new List <AccessPassModel>();
                objModel.ListAP.AddRange(objList);
                foreach (var i in objModel.ListAP)
                {
                    int id = i.APID;
                    objModel = objService.getByID(id);
                    Dbcontext.AccessPassMasters.Remove(Dbcontext.AccessPassMasters.Find(id));
                    Dbcontext.SaveChanges();
                }
                int c = objList.Count();
                TempData["Msg"] = c + "Record Deleted.";
            }
            catch (Exception ex)
            {
                TempData["Msg"] = "Record Not Deleted. " + ex;
                return(View("Error"));
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id)
        {
            AccessPassService objService = new AccessPassService();
            AccessPassModel   objModel   = new AccessPassModel();

            objModel = objService.getByID(id);

            UserService         objService1 = new UserService();
            List <CompanyModel> ListComp    = new List <CompanyModel>();

            ListComp          = objService1.getActiveComp();
            objModel.ListComp = new List <CompanyModel>();
            objModel.ListComp.AddRange(ListComp);


            return(View(objModel));
        }
 public ActionResult Delete(int id)
 {
     try
     {
         AccessPassService objService = new AccessPassService();
         AccessPassModel   objModel   = new AccessPassModel();
         objModel = objService.getByID(id);
         Dbcontext.AccessPassMasters.Remove(Dbcontext.AccessPassMasters.Find(id));
         TempData["Msg"] = "Record Deleted.";
         Dbcontext.SaveChanges();
     }
     catch (Exception ex)
     {
         TempData["Msg"] = "Record Not Deleted.";
         return(View("Error"));
     }
     return(RedirectToAction("Index"));
 }