public async Task <IActionResult> Update(CurrentUpdateView model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.Name);

                user.Name     = model.Name;
                user.Surname  = model.Surname;
                user.UserName = model.UserName;
                user.City     = model.City;

                user.Email = model.Email;
                user.Id    = model.Id;


                await _userManager.UpdateSecurityStampAsync(user);

                var result = await _userManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                foreach (var item in result.Errors)
                {
                    ModelState.AddModelError("", item.Description);
                }
            }
            return(View(model));
        }
Exemple #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var deger = await _userManager.FindByNameAsync(User.Identity.Name);

            CurrentUpdateView current = new CurrentUpdateView()
            {
                City     = deger.City,
                Surname  = deger.Surname,
                Email    = deger.Email,
                Id       = deger.Id,
                Name     = deger.Name,
                UserName = deger.UserName
            };

            return(View("Update", current));
        }