示例#1
0
        public List <SuggestionModel> GetSuggestions(ICollection <int> ids)
        {
            var list = new List <SuggestionModel>();

            foreach (int id in ids)
            {
                var profile     = new UserProfileHandler().Get(id);
                var user        = new UserHandler().Get(profile.Entity.UserId);
                var gender      = new GenderHandler().Get(profile.Entity.GenderId);
                var status      = new MaritalStatusHandler().Get(profile.Entity.StatusId);
                var religion    = new ReligionHandler().Get(profile.Entity.ReligionId);
                var orientation = new OrientationHandler().Get(profile.Entity.OrientationId);

                if (!profile.CompletedRequest || !user.CompletedRequest || !gender.CompletedRequest || !status.CompletedRequest || !religion.CompletedRequest || !orientation.CompletedRequest)
                {
                    return(null);
                }

                var suggestionModel = new SuggestionModel
                {
                    UserName    = user.Entity.UserUsername,
                    Description = string.IsNullOrEmpty(profile.Entity.UserProfileDescription) ? "This user has not provided a description." : profile.Entity.UserProfileDescription,
                    FullName    = profile.Entity.UserProfileName + " " + profile.Entity.UserProfileSurname,
                    Age         = AgeCalculator.GetDifferenceInYears(profile.Entity.UserProfileBirthday, DateTime.Now).ToString(),
                    Gender      = gender.Entity.GenderName,
                    Orientation = orientation.Entity.OrientationName,
                    Religion    = religion.Entity.ReligionName,
                    Status      = status.Entity.StatusName
                };

                list.Add(suggestionModel);
            }
            return(list);
        }
示例#2
0
        public static IEnumerable <SelectListItem> GetStatuses()
        {
            MaritalStatusHandler statusHandler = new MaritalStatusHandler();
            var statuses = statusHandler.GetAll();

            if (statuses.CompletedRequest)
            {
                var list = statuses.Entity.Select(x =>
                                                  new SelectListItem
                {
                    Value = x.StatusId.ToString(),
                    Text  = x.StatusName
                });

                return(new SelectList(list, "Value", "Text"));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        public ProfileModel GetProfileModel(UserEntity user, UserProfileEntity profile, AddressEntity address)
        {
            var gender      = new GenderHandler().Get(profile.GenderId);
            var status      = new MaritalStatusHandler().Get(profile.StatusId);
            var religion    = new ReligionHandler().Get(profile.ReligionId);
            var orientation = new OrientationHandler().Get(profile.OrientationId);
            var starsign    = new StarSignHandler().Get(profile.StarsignId);

            var likesHandler = new PreferenceHandler();
            var likes        = likesHandler.GetAllForUserProfile(profile.UserProfileId, true);
            var dislikes     = likesHandler.GetAllForUserProfile(profile.UserProfileId, false);

            if (!gender.CompletedRequest || !status.CompletedRequest || !religion.CompletedRequest || !orientation.CompletedRequest || !starsign.CompletedRequest || !likes.CompletedRequest || !dislikes.CompletedRequest)
            {
                return(null);
            }

            var profileModel = new ProfileModel
            {
                UserName    = user.UserUsername,
                Job         = string.IsNullOrEmpty(profile.UserProfileJob) ? "This user has not provided information about their job." : profile.UserProfileJob,
                Description = string.IsNullOrEmpty(profile.UserProfileDescription) ? "This user has not provided a description." : profile.UserProfileDescription,
                FullName    = profile.UserProfileName + " " + profile.UserProfileSurname,
                Address     = (address == null) ? "No address information." : address.AddressCity + ", " + address.AddressCountry,
                Birthday    = DateFormatter.GetDate(profile.UserProfileBirthday),
                Age         = AgeCalculator.GetDifferenceInYears(profile.UserProfileBirthday, DateTime.Now).ToString(),
                Gender      = gender.Entity.GenderName,
                Orientation = orientation.Entity.OrientationName,
                Religion    = religion.Entity.ReligionName,
                Status      = status.Entity.StatusName,
                Starsign    = starsign.Entity.SignName,
                Motto       = string.IsNullOrEmpty(profile.Motto) ? "-" : profile.Motto,
                Likes       = likes.Entity.Count > 0 ? likes.Entity.Select(x => x.Name).ToList() : null,
                Dislikes    = dislikes.Entity.Count > 0 ? dislikes.Entity.Select(x => x.Name).ToList() : null,
            };

            return(profileModel);
        }