Пример #1
0
        //[ValidateAntiForgeryToken]
        public ActionResult UpdateUser(string id, MyProfileInfo objProfile)
        {
            ApplicationUser usr = db.Users.Find(id);

            objProfile.UserName = usr.UserName;
            if (ModelState.IsValid)
            {
                usr.Name            = objProfile.Name;
                usr.Email           = objProfile.Email;
                usr.FlatNo          = objProfile.FlatNo;
                db.Entry(usr).State = EntityState.Modified;
                db.SaveChanges();


                var formCollection = new FormCollection(HttpContext.Request.Form);
                if (formCollection["ResetPass"].ToString().ToLower() != "false")
                {
                    var token  = UserManager.GenerateEmailConfirmationToken(id);
                    var result = UserManager.ResetPassword(id, token, "abcd@1234");
                    if (result.Succeeded)
                    {
                        if (!string.IsNullOrEmpty(usr.Email))
                        {
                            EmailNotification ygcemail = new EmailNotification();
                            ygcemail.SendForgetPasswordEmail(usr, "abcd@1234");
                            ygcemail = null;
                        }
                    }
                }
                return(RedirectToAction("Users"));
            }
            return(View(objProfile));
        }
Пример #2
0
        //[ValidateAntiForgeryToken]
        public ActionResult MyProfile(MyProfileInfo objProfile)
        {
            var             userId = User.Identity.GetUserId();
            ApplicationUser usr    = db.Users.Find(userId);

            objProfile.UserName = usr.UserName;
            if (ModelState.IsValid)
            {
                usr.Name            = objProfile.Name;
                usr.Email           = objProfile.Email;
                usr.FlatNo          = objProfile.FlatNo;
                db.Entry(usr).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess }));
            }
            return(View(objProfile));
        }
Пример #3
0
        public ActionResult UpdateUser(string id)
        {
            ApplicationUser usr = db.Users.Find(id);

            if (usr == null)
            {
                return(HttpNotFound());
            }
            else
            {
                MyProfileInfo objProfile = new MyProfileInfo();
                objProfile.Name     = usr.Name;
                objProfile.Email    = usr.Email;
                objProfile.UserName = usr.UserName;
                objProfile.FlatNo   = usr.FlatNo;
                return(View(objProfile));
            }
        }
Пример #4
0
        public ActionResult MyProfile()
        {
            var             userId = User.Identity.GetUserId();
            ApplicationUser usr    = db.Users.Find(userId);

            if (usr == null)
            {
                return(HttpNotFound());
            }
            else
            {
                MyProfileInfo objProfile = new MyProfileInfo();
                objProfile.Name     = usr.Name;
                objProfile.Email    = usr.Email;
                objProfile.UserName = usr.UserName;
                objProfile.FlatNo   = usr.FlatNo;
                return(View(objProfile));
            }
        }