Ejemplo n.º 1
0
        public ActionResult EditProfileInfo()
        {
            string id = User.Identity.GetUserId();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EditProfileInfoViewModel profileInfo = EditProfileInfoViewModel.Create(UserManager.GetFirstName(id), UserManager.GetLastName(id), UserManager.GetPhoneNumber(id), UserManager.GetEmail(id));

            if (profileInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(profileInfo));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> EditProfileInfo([Bind(Include = "FirstName,LastName,Phone,Email")] EditProfileInfoViewModel editProfileInfoViewModel)
        {
            if (ModelState.IsValid)
            {
                //must NOT edit email adress
                string          id   = User.Identity.GetUserId();
                ApplicationUser user = newUserManager.FindById(id);
                user.FirstName   = editProfileInfoViewModel.FirstName;
                user.LastName    = editProfileInfoViewModel.LastName;
                user.PhoneNumber = editProfileInfoViewModel.Phone;
                await db.SaveChangesAsync();

                ViewBag.StatusMessage = "Profilinformasjonen ble endret!";
                return(RedirectToAction("Index", new
                {
                    Message = ManageMessageId.EditProfileInfoSuccess
                }));
            }
            return(View(editProfileInfoViewModel));
        }