Beispiel #1
0
        public ActionResult Edit(EditUserModel model)
        {
            if (ModelState.IsValid)
            {
                if (IsValidCountryAndStates(model.Country, model.State))
                {
                    MainUser u = UserHelper.MapEditUserModelToUser(model);
                    _empRepo.Edit(u);
                    LogActivity("Edit User", model.UserName + " is Edited by " + User.Identity.Name);

                    return(RedirectToAction("Index", "Employees"));
                }
                ModelState.AddModelError("Country", "Country or state is invalid");
            }

            model.Countries = GetCountries();
            return(View(model));
        }
Beispiel #2
0
        public void RecordAndLockIfExceedLoginAttemp(string userName)
        {
            MainUser u = _empRepo.GetByUserName(userName);

            if (u.LastLoginAttemp.HasValue && IsWithin6Hours(u.LastLoginAttemp.Value))
            {
                if (u.NumberOfWrongLogin >= 3)
                {
                    _empRepo.Lock(userName);
                }
                else  //Update last failed login and login attemp;
                {
                    u.NumberOfWrongLogin = u.NumberOfWrongLogin + 1;
                }
            }
            else  //Reset login attemp to 1;
            {
                u.NumberOfWrongLogin = 1;
            }

            u.LastLoginAttemp = DateTime.Now;
            _empRepo.Edit(u);
        }