Ejemplo n.º 1
0
        private string GetUserName(string userId)
        {
            var db = new BarkerData();
            AspNetUser AspNetUser = db.AspNetUsers.Find(userId);

            return AspNetUser.UserName;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }