Ejemplo n.º 1
0
        public async Task<ActionResult> Manager(EditProfileViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Get the current application user

                ApplicationUser Model = UserManager.FindById(User.Identity.GetUserId());
                // Update the details
                Model.Email = model.Email;
                Model.DateOfBirth = model.DateOfBirth;
                Model.FirstName = model.FirstName;
                Model.LastName = model.LastName;
                Model.UserName = model.FirstName + "." + model.LastName;
                Model.AppartementNumber = model.AppartementNumber;
                Model.BuildingNumber = model.BuildingNumber;

                IdentityResult result = await UserManager.UpdateAsync(Model);
                @Session["username"] = Model.UserName;
                // However, it always succeeds inspite of not updating the database
                if (!result.Succeeded)
                {
                    AddErrors(result);
                }
    
            }

            return RedirectToAction("Manager");
        }
Ejemplo n.º 2
0
        //
        // GET: /Manage/Manage
        public ActionResult Manager()
        {
            ApplicationUser Model = UserManager.FindById(User.Identity.GetUserId());
            EditProfileViewModel oldUser = new EditProfileViewModel();
            oldUser.FirstName = Model.FirstName;
            oldUser.LastName = Model.LastName;
            oldUser.Email = Model.Email;
            oldUser.DateOfBirth = Model.DateOfBirth;
            oldUser.BuildingNumber = Model.BuildingNumber;
            oldUser.AppartementNumber = Model.AppartementNumber;
            ViewBag.dateString = oldUser.DateOfBirth.ToString("yyyy-MM-dd");

            return View(oldUser);
        }