public async Task <IActionResult> Edit([Bind("Id,UserName,Email,BirthDate,Bio,Gender,Nickname")] User user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User u = await _userManager.FindByIdAsync(user.Id);

                    u.BirthDate = user.BirthDate;
                    u.Bio       = user.Bio;
                    u.Gender    = user.Gender;
                    u.Nickname  = user.Nickname;
                    await _userManager.UpdateAsync(u);

                    //context.Update(user);
                    //context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(RedirectToAction(actionName: "Profile", controllerName: "User"));
        }
Exemple #2
0
        public async Task <IActionResult> UpdateGuestCustomerinfo([FromBody] EditGuestUser value)
        {
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var appuser = new AppUser()
            {
                UserName    = value.Name,
                Email       = value.Email,
                PhoneNumber = value.PhoneNo
            };

            if (user != null)
            {
                await _userManager.UpdateAsync(appuser);

                return(Ok());
            }
            return(NotFound());
        }