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 Index(AccessPassModel model)
        {
            AccessPassService      objService = new AccessPassService();
            AccessPassModel        objModel   = new AccessPassModel();
            List <AccessPassModel> objList    = new List <AccessPassModel>();
            int cid = 0;

            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }
            int mm = Convert.ToInt32(model.month);
            int yy = Convert.ToInt32(model.year);

            objList         = objService.getAPDataByMMYY(cid, mm, yy);
            objModel.ListAP = new List <AccessPassModel>();
            objModel.ListAP.AddRange(objList);

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

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

            return(View(objModel));
        }
        //
        // GET: /APIAccessPass/

        public IEnumerable <AccessPassModel> Get(int id)
        {
            AccessPassModel        objModel   = new AccessPassModel();
            AccessPassService      objService = new AccessPassService();
            List <AccessPassModel> lstuser    = new List <AccessPassModel>();

            lstuser = objService.getAPData(id);
            return(lstuser);
        }
        public ActionResult Edit(AccessPassModel model)
        {
            AccessPassService objService = new AccessPassService();

            model.SwipeTime = Convert.ToDateTime(model.SwipeTime);
            objService.Update(model);
            TempData["Msg"] = "Updated Successfully.";
            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"));
 }