Esempio n. 1
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if(ModelState.IsValid)
            {
                var user = (model.UserType == Helpers.Enumerations.LogedUserTypeEnum.Poedinec) ?
                    _qPoedinec.GetLogiranPoedinec(model.UserName, model.OldPassword) :
                    _qKompanija.GetLogiranaKompanija(model.UserName, model.OldPassword);

                if(user != null)
                {
                    Func<int, string, bool> changePassFunc = null;
                    if (model.UserType == Helpers.Enumerations.LogedUserTypeEnum.Poedinec)
                        changePassFunc = _qPoedinec.ChangePassword;
                    else if (model.UserType == Helpers.Enumerations.LogedUserTypeEnum.Kompanija)
                        changePassFunc = _qKompanija.ChangePassword;

                    if (changePassFunc != null && changePassFunc(user.Id, model.NewPassword))
                        return RedirectToAction("Login", new { message = ManageMessageId.ChangePasswordSuccess });
                    else
                        ModelState.AddModelError("", "Лозинката не е успешно променета");
                }
                else
                {
                    ModelState.AddModelError("", "Корисничкото Име или Лозинката не се совпаѓаат");
                }

            }
            //If we got this far, something failed, redisplay form
            return View(model);
        }
Esempio n. 2
0
        public ActionResult ChangePassword(LogedUserTypeEnum userType = 0)
        {
            //validate the userType parameter
            if ((int)userType > 1)
                return RedirectToAction("Login");

            var model = new ChangePasswordModel();
            model.UserType = userType;
            return View(model);
        }