Example #1
0
        public async Task<ActionResult> ChangeUserName(ChangeUserNameViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            var db = new BarkerData();
            var self = User.Identity.GetUserId();
            AspNetUser AspNetUser = db.AspNetUsers.Find(self);
           
            if (AspNetUser != null)
            {

                AspNetUser.UserName = model.NewUsername;
                db.SaveChanges();
                return RedirectToAction("Index", new { Message = "Username has been changed." });
            }
           // AddErrors(result);
            return View(model);
        }
Example #2
0
        //
        // GET: /Manage/ChangePassword
        public ActionResult ChangeUserName()
        {
            var db = new BarkerData();
            var self = User.Identity.GetUserId();
            AspNetUser AspNetUser = db.AspNetUsers.Find(self);
            var vm = new ChangeUserNameViewModel();
            vm.OldUsername = AspNetUser.UserName;

            return View(vm);
        }