//public ActionResult ChangePassword(ChangePassword newPassword)
        public ActionResult ChangePassword(FormCollection form)
        {
            var     oldPwd       = form["OldPassword"];
            var     oldPwdHash   = PasswordGenerator.HashPassword(oldPwd);
            var     newPwd       = form["newPassword"];
            string  userCategory = string.Empty;
            UCMUser user         = new UCMUser();

            if (StaticVariables.Role.Equals("Student"))
            {
                userCategory = "Student";
                user         = StaticVariables.StudentDetails.FirstOrDefault(p => p.Id == int.Parse(User.Identity.Name));
            }
            else
            {
                userCategory = "Advisor";
                user         = StaticVariables.AdvisorDetails.FirstOrDefault(p => p.Id == Convert.ToInt32(User.Identity.Name));
            }
            if (oldPwdHash.Equals(user.Password))
            {
                var newPwdHash = PasswordGenerator.HashPassword(newPwd);
                user.Password = newPwdHash;
                bool updateStatus = ContactApi.PostToApi <UCMUser>(user, "updateUser");
                if (updateStatus)
                {
                    return(RedirectToAction(userCategory, "Home"));
                }
            }
            return(View());
        }
Example #2
0
        public IHttpActionResult updateUser([FromBody] UCMUser user)
        {
            IUnitOfWork unitOfWork = new UnitOfWork(new Entities());

            unitOfWork.UserInfo.Update(user);
            if (unitOfWork.Save() >= 1)
            {
                return(Ok("Success"));
            }
            return(BadRequest("There is an error"));
        }
Example #3
0
        public ActionResult CreatePassword(int id)
        {
            UCMUser user        = StaticVariables.AdvisorDetails.FirstOrDefault(p => p.Id == id);
            string  password    = PasswordGenerator.GeneratePassword();
            string  md5Password = PasswordGenerator.HashPassword(password);

            user.Password = md5Password;
            bool status = ContactApi.PostToApi(user, "updateUser");

            ViewBag.Status = status;
            return(View());
        }