public ActionResult EditProfile(UserProfileFormModel editedProfile) { UserProfile user = Mapper.Map<UserProfileFormModel, UserProfile>(editedProfile); ApplicationUser applicationUser = userService.GetUser(editedProfile.UserId); applicationUser.FirstName = editedProfile.FirstName; applicationUser.LastName = editedProfile.LastName; applicationUser.Email = editedProfile.Email; if (ModelState.IsValid) { userService.UpdateUser(applicationUser); userProfileService.UpdateUserProfile(user); return RedirectToAction("UserProfile", new { id = editedProfile.UserId }); } return PartialView("EditProfile", editedProfile); }
public void Editprofile_Post() { var userManager = new UserManager<ApplicationUser>(new TestUserStore()); ApplicationUser applicationUser = new ApplicationUser() { Activated = true, Email = "*****@*****.**", FirstName = "Adarsh", LastName = "Vikraman", UserName = "******", RoleId = 0, Id = "402bd590-fdc7-49ad-9728-40efbfe512ec" }; userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(applicationUser); UserProfileFormModel profile = new UserProfileFormModel(); Mapper.CreateMap<UserProfileFormModel, UserProfile>(); profile.FirstName ="adarsh"; AccountController contr = new AccountController(userService, userProfileService, goalService, updateService, commentService, followRequestService, followUserService, securityTokenService,userManager); var result = contr.EditProfile(profile) as RedirectToRouteResult; Assert.AreEqual("UserProfile", result.RouteValues["action"]); }
public void Editprofile_Post() { var userManager = new UserManager<ApplicationUser>(new TestUserStore()); ApplicationUser applicationUser = getApplicationUser(); userRepository.Setup(x => x.Get(It.IsAny<Expression<Func<ApplicationUser, bool>>>())).Returns(applicationUser); UserProfileFormModel profile = new UserProfileFormModel(); Mapper.CreateMap<UserProfileFormModel, UserProfile>(); profile.FirstName ="adarsh"; AccountController contr = new AccountController(userService, userProfileService, goalService, updateService, commentService, followRequestService, followUserService, securityTokenService,userManager); var result = contr.EditProfile(profile) as RedirectToRouteResult; Assert.AreEqual("UserProfile", result.RouteValues["action"]); }