public static ProfileViewModel ToProfileViewModel(this ProfileDetails profileDetails) { var profileViewModel = new ProfileViewModel(); AutoMapper.Mapper.Map(profileDetails, profileViewModel); return profileViewModel; }
public void ToProfileDetails_Returns_Model_WithSameValues() { // Arrange var profileViewModel = new ProfileViewModel() { Id = 5, Name = "Test Profile", ContactUserId = 10, }; // Act var result = profileViewModel.ToProfileDetails(); // Assert Assert.IsTrue(result.ContactUserId == profileViewModel.ContactUserId && result.Id == profileViewModel.Id && result.Name == profileViewModel.Name); }
public void ToProfileDetails_Returns_Model_With_Correct_ArePDfs_Flag() { // Arrange var profileViewModel = new ProfileViewModel() { Id = 5, Name = "Test Profile", ContactUserId = 10, SelectedPdfAreaTypes = new List<ProfileAreaType>() { new ProfileAreaType() {Id = 10, Value ="Test Area 1" }, new ProfileAreaType() {Id = 11, Value ="Test Area 2" }, new ProfileAreaType() {Id = 12, Value ="Test Area 3" } } }; // Act var result = profileViewModel.ToProfileDetails(); // Assert Assert.IsTrue(result.ArePdfs == true); }
public ActionResult EditProfile(ProfileViewModel profileViewModel) { profileViewModel.SelectedPdfAreaTypes = JsonConvert.DeserializeObject<IEnumerable<ProfileAreaType>>(Request["SelectedPdfAreaTypes"]); profileViewModel.ProfileUsers = JsonConvert.DeserializeObject<IEnumerable<ProfileUser>>(Request["ProfileUsers"]); var profile = profileViewModel.ToProfileDetails(); ProfileDetailsCleaner.CleanUserInput(profile); _profileRepository.UpdateProfile(profile); return RedirectToAction("ManageProfiles"); }
public ActionResult CreateProfile(ProfileViewModel profileViewModel) { profileViewModel.ProfileUsers = JsonConvert.DeserializeObject<IEnumerable<ProfileUser>>(Request["ProfileUsers"]); // Create new profile var profile = profileViewModel.ToProfileDetails(); profile.SetDefaultValues(); var userName = UserDetails.CurrentUser().Name; int newProfileId = _profileRepository.CreateProfile(profile); // New domain _writer.NewGroupingMetadata(profile.DefaultDomainName, 1, newProfileId); // Create default content items new DefaultProfileContentWriter(_writer, newProfileId, userName) .CreateContentItems(); return RedirectToAction("ManageProfiles"); }
public ActionResult CreateProfile() { var profileViewModel = new ProfileViewModel() { ProfileUsers = new List<ProfileUser>(), }; if (HttpContext.Request.UrlReferrer != null) { profileViewModel.ReturnUrl = HttpContext.Request.UrlReferrer.ToString(); } ViewBag.AllUsers = _userRepository.GetAllFpmUsers().ToProfileUserList(); ViewBag.ContactUserId = GetFpmUserList(); return View("CreateProfile", profileViewModel); }
public void ToProfileDetails_Returns_Model_With_UserPermissions() { // Arrange var profileViewModel = new ProfileViewModel() { Id = 5, Name = "Test Profile", ContactUserId = 10, ProfileUsers = new List<ProfileUser>() { new ProfileUser() {Id = 10, Name ="Test Name 1" }, new ProfileUser() {Id = 11, Name ="Test Area 2" }, new ProfileUser() {Id = 12, Name ="Test Area 3" } } }; // Act var result = profileViewModel.ToProfileDetails(); // Assert Assert.IsTrue(result.UserPermissions != null && result.UserPermissions.Any() && result.UserPermissions.ToList()[0].UserId == profileViewModel.ProfileUsers.ToList()[0].Id); }