Esempio n. 1
0
        public void GetProfileShouldReturnFullEditProfileModel(Db db, [Substitute] UserProfile userProfile, [RightKeys("FirstName", "LastName", "Phone", "Interest")] IDictionary <string, string> properties,
                                                               [Frozen] IProfileSettingsService profileSettingsService, [Frozen] IUserProfileProvider userProfileProvider, [Greedy] UserProfileService userProfileService)
        {
            using (db)
            {
                var id = new ID();
                db.Add(new DbItem("Profile", id)
                {
                    Fields =
                    {
                        new DbField("FirstName", Templates.UserProfile.Fields.FirstName),
                        new DbField("LastName",  Templates.UserProfile.Fields.LastName),
                        new DbField("Phone",     Templates.UserProfile.Fields.PhoneNumber),
                        new DbField("Interest",  Templates.UserProfile.Fields.Interest)
                    }
                });
                profileSettingsService.GetUserDefaultProfile().Returns(db.GetItem(id));
                userProfileProvider.GetCustomProperties(Arg.Any <UserProfile>()).Returns(properties);

                var result = userProfileService.GetProfile(userProfile);
                result.FirstName.Should().Be(properties["FirstName"]);
                result.LastName.Should().Be(properties["LastName"]);
                result.PhoneNumber.Should().Be(properties["Phone"]);
                result.Interest.Should().Be(properties["Interest"]);
            }
        }
Esempio n. 2
0
        public virtual EditProfile GetProfile(User user)
        {
            SetProfileIfEmpty(user);

            var properties = _userProfileProvider.GetCustomProperties(user.Profile);

            var model = new EditProfile
            {
                Email         = user.Profile.Email,
                FirstName     = user.Profile.Name ?? "",
                LastName      = user.Profile.GetCustomProperty("LastName") ?? "",
                PhoneNumber   = user.Profile.GetCustomProperty("Phone") ?? "",
                Interest      = properties.ContainsKey(Constants.UserProfile.Fields.Interest) ? properties[Constants.UserProfile.Fields.Interest] : "",
                InterestTypes = _profileSettingsService.GetInterests()
            };

            return(model);
        }
Esempio n. 3
0
        public virtual EditProfile GetProfile(User user)
        {
            SetProfileIfEmpty(user);

            var properties  = _userProfileProvider.GetCustomProperties(user.Profile);
            var contactData = _contactFacetsService.GetContactData();

            var model = new EditProfile
            {
                Email         = user.Profile.Email,
                FirstName     = user.Profile.GetCustomProperty(Constants.UserProfile.Fields.FirstName) ?? "",
                LastName      = user.Profile.GetCustomProperty(Constants.UserProfile.Fields.LastName) ?? "",
                PhoneNumber   = user.Profile.GetCustomProperty(Constants.UserProfile.Fields.PhoneNumber) ?? "",
                Interest      = properties.ContainsKey(Constants.UserProfile.Fields.Interest) ? properties[Constants.UserProfile.Fields.Interest] : "",
                InterestTypes = _profileSettingsService.GetInterests(),
                SportType     = contactData.SportType,
                SportName     = contactData.SportName
            };

            return(model);
        }