public UserProfileEntity ToDataEntity(UserModel model, UserProfileEntity userProfile)
        {
            var starSign = new StarSignHandler().GetByName(StarsignCalculator.GetStarsignName(model.Birthday));

            if (!starSign.CompletedRequest)
            {
                return(null);
            }

            return(new UserProfileEntity
            {
                UserProfileId = userProfile.UserProfileId,
                UserAge = AgeCalculator.GetDifferenceInYears(model.Birthday, DateTime.Now),
                UserProfileBirthday = model.Birthday,
                UserProfileName = model.Name,
                UserProfileSurname = model.Surname,
                UserProfileDescription = model.Description,
                UserProfileJob = model.Job,
                UserProfilePhone = model.Phone,
                GenderId = model.GenderId,
                OrientationId = model.OrientationId,
                StatusId = model.StatusId,
                ReligionId = model.ReligionId,
                UserId = userProfile.UserId,
                Motto = model.Motto,
                StarsignId = starSign.Entity.SignId
            });
        }
        private void PopulateModel(UserModel userModel, UserEntity user, UserProfileEntity userProfile)
        {
            userModel.Religions      = SelectListGenerator.GetSelectedReligions(userProfile);
            userModel.Statuses       = SelectListGenerator.GetSelectedStatuses(userProfile);
            userModel.Orientations   = SelectListGenerator.GetSelectedOrientations(userProfile);
            userModel.Genders        = SelectListGenerator.GetSelectedGenders(userProfile);
            userModel.Email          = user.UserEmail;
            userModel.UserName       = user.UserUsername;
            userModel.Description    = string.IsNullOrWhiteSpace(userProfile.UserProfileDescription) ? "" : userProfile.UserProfileDescription;
            userModel.Phone          = string.IsNullOrWhiteSpace(userProfile.UserProfilePhone) ? "" : userProfile.UserProfilePhone;
            userModel.Job            = string.IsNullOrWhiteSpace(userProfile.UserProfileJob) ? "" : userProfile.UserProfileJob;
            userModel.Name           = userProfile.UserProfileName;
            userModel.Surname        = userProfile.UserProfileSurname;
            userModel.ReligionId     = userProfile.ReligionId;
            userModel.StatusId       = userProfile.StatusId;
            userModel.OrientationId  = userProfile.OrientationId;
            userModel.GenderId       = userProfile.GenderId;
            userModel.Age            = AgeCalculator.GetDifferenceInYears(userProfile.UserProfileBirthday, DateTime.Now);
            userModel.Birthday       = userProfile.UserProfileBirthday;
            userModel.BirthdayString = DateFormatter.GetDate(userProfile.UserProfileBirthday);
            userModel.Starsign       = StarsignCalculator.GetStarsignName(userProfile.UserProfileBirthday);
            userModel.Motto          = string.IsNullOrWhiteSpace(userProfile.Motto) ? "" : userProfile.Motto;

            var prefHandler = new PreferenceHandler();

            userModel.LikesList    = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, true).Entity.ToList();
            userModel.DislikesList = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, false).Entity.ToList();
        }
Beispiel #3
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);
        }
        public static bool Over18Years(DateTime birthday)
        {
            if (AgeCalculator.GetDifferenceInYears(birthday, DateTime.Now) < 18)
            {
                return(false);
            }

            return(true);
        }
        public bool CheckUpdatedUser(UserModel userModel, UserProfileEntity userProfileEntity)
        {
            userModel.Age = AgeCalculator.GetDifferenceInYears(userModel.Birthday, DateTime.Now);

            var userHandler = new UserHandler();
            var userEntity  = userHandler.Get(userProfileEntity.UserId);

            if (!userEntity.CompletedRequest || userEntity.Entity == null)
            {
                return(false);
            }

            if (NoChanges(userModel, userProfileEntity, userEntity.Entity))
            {
                InvalidInfoMessage = MessageConstants.NoChangesMade;
                return(false);
            }

            var validator           = new UpdatedUserValidator();
            ValidationResult result = validator.Validate(userModel);

            if (!result.IsValid)
            {
                InvalidInfoMessage = ErrorMessageGenerator.ComposeErrorMessage(result);
                return(false);
            }

            if (userModel.Email != userEntity.Entity.UserEmail && userHandler.CheckExistingEmail(userModel.Email))
            {
                InvalidInfoMessage = MessageConstants.ExistingEmailMessage;
                return(false);
            }

            if (userModel.UserName != userEntity.Entity.UserUsername && userHandler.CheckExistingUsername(userModel.UserName))
            {
                InvalidInfoMessage = MessageConstants.ExistingUsernameMessage;
                return(false);
            }

            return(true);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        private UserProfileEntity ToDataEntity(RegisterModel model, int userId)
        {
            var starSignName     = StarsignCalculator.GetStarsignName(model.UserProfileBirthday);
            var starSignResponse = new StarSignHandler().GetByName(starSignName);

            if (!starSignResponse.CompletedRequest)
            {
                return(null);
            }

            return(new UserProfileEntity
            {
                UserAge = AgeCalculator.GetDifferenceInYears(model.UserProfileBirthday, DateTime.Now),
                UserProfileBirthday = model.UserProfileBirthday,
                UserProfileName = model.UserProfileName,
                UserProfileSurname = model.UserProfileSurname,
                GenderId = model.GenderId,
                OrientationId = model.OrientationId,
                StatusId = model.StatusId,
                ReligionId = model.ReligionId,
                UserId = userId,
                StarsignId = starSignResponse.Entity.SignId
            });
        }