Пример #1
0
        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"));
        }
Пример #2
0
        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));
        }
        public async Task <IActionResult> CreateToken([FromBody] LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = await _userManager.FindByNameAsync(model.Email);

            if (user == null)
            {
                return(Unauthorized());
            }

            if (_passwordHasher.VerifyHashedPassword(user, user.PasswordHash, model.Password) != PasswordVerificationResult.Success)
            {
                return(Unauthorized());
            }

            var currentClaims = await _userManager.GetClaimsAsync(user);

            var accessPass = new AccessPassModel
            {
                Token  = _tokenFactory.CreateToken(user, currentClaims),
                Player = new PlayerModel
                {
                    Id       = user.Id,
                    NickName = user.NickName
                }
            };

            return(Ok(accessPass));
        }
Пример #4
0
        public int Update(AccessPassModel model)
        {
            Mapper.CreateMap <AccessPassModel, AccessPassMaster>();
            AccessPassMaster objUser = Dbcontext.AccessPassMasters.SingleOrDefault(m => m.APID == model.APID);

            objUser = Mapper.Map(model, objUser);
            return(Dbcontext.SaveChanges());
        }
        //
        // 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);
        }
Пример #6
0
        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"));
        }
Пример #7
0
 public AccessPassModel getByID(int id)
 {
     try
     {
         Mapper.CreateMap <AccessPassMaster, AccessPassModel>();
         AccessPassMaster objCityMaster = Dbcontext.AccessPassMasters.Where(m => m.APID == id).SingleOrDefault();
         AccessPassModel  objCityItem   = Mapper.Map <AccessPassModel>(objCityMaster);
         return(objCityItem);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #8
0
        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));
        }
Пример #9
0
 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"));
 }