Beispiel #1
0
        private void LoadFilteredUsers(bool isAjax, FindUsersModel model)
        {
            model.AgeFrom = (!string.IsNullOrWhiteSpace(Request.QueryString["AgeFrom"])) ? Convert.ToInt32(Request.QueryString["AgeFrom"]) : model.AgeFrom;
            model.AgeTo = (!string.IsNullOrWhiteSpace(Request.QueryString["AgeTo"])) ? Convert.ToInt32(Request.QueryString["AgeTo"]) : model.AgeTo;

            mu = Membership.GetUser();

            if (mu != null)
            {
                // there aren't enough results for this filter

                //ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey));
                //uad = new UserAccountDetail();
                //uad.GetUserAccountDeailForUser(ua.UserAccountID);

                //model.InterestedInID = ReverseInterestYouAreByName(uad.YouAreID);
                //model.RelationshipStatusID = uad.RelationshipStatusID;
                //model.YouAreID = ReverseYouAreByInterestName(uad.InterestedInID);
                //model.Lang = uad.DefaultLanguage;
                //model.PostalCode = uad.PostalCode;
                //model.Country = uad.Country;

                //if (uad.YearsOld > model.AgeTo)
                //{
                //    // they are old(er)
                //    model.AgeFrom = 30;
                //    model.AgeTo = 69;
                //}
            }

            model.InterestedInID =
                    (Request.QueryString["InterestedInID"] != null && Request.QueryString["InterestedInID"] == string.Empty) ? null :
                    (Request.QueryString["InterestedInID"] == null) ? model.InterestedInID : Convert.ToInt32(Request.QueryString["InterestedInID"]);

            model.RelationshipStatusID =
            (Request.QueryString["RelationshipStatusID"] != null && Request.QueryString["RelationshipStatusID"] == string.Empty) ? null :
            (Request.QueryString["RelationshipStatusID"] == null) ? model.RelationshipStatusID : Convert.ToInt32(Request.QueryString["RelationshipStatusID"]);

            model.YouAreID =
            (Request.QueryString["YouAreID"] != null && Request.QueryString["YouAreID"] == string.Empty) ? null :
            (Request.QueryString["YouAreID"] == null) ? model.YouAreID : Convert.ToInt32(Request.QueryString["YouAreID"]);

            model.Lang = (Request.QueryString["lang"] != null && Request.QueryString["lang"] == string.Empty) ? null :
            (Request.QueryString["lang"] == null) ? model.Lang : Request.QueryString["lang"];

            model.PostalCode
                = (Request.QueryString["postalcode"] != null && Request.QueryString["postalcode"] == string.Empty) ? null :
            (Request.QueryString["postalcode"] == null) ? model.PostalCode : Request.QueryString["postalcode"];

            model.Country
                = (Request.QueryString["country"] != null && Request.QueryString["country"] == string.Empty) ? null :
            (Request.QueryString["country"] == null) ? model.Country : Request.QueryString["country"];

            uas = new UserAccounts();

            bool sortByDistance = false;

            uas.GetListUsers(userPageNumber, pageSize, model.AgeFrom, model.AgeTo, model.InterestedInID, model.RelationshipStatusID,
                model.YouAreID, model.Country, model.PostalCode, model.Lang, out sortByDistance);

            if (!isAjax)
            {
                ViewBag.SortByDistance = sortByDistance;
            }
        }
        private void LoadFilteredUsers(bool isAjax, FindUsersModel model)
        {
            _mu = MembershipWrapper.GetUser();

            model.AgeFrom = (!string.IsNullOrWhiteSpace(Request.QueryString["AgeFrom"]))
                ? Convert.ToInt32(Request.QueryString["AgeFrom"])
                : model.AgeFrom;
            model.AgeTo = (!string.IsNullOrWhiteSpace(Request.QueryString["AgeTo"]))
                ? Convert.ToInt32(Request.QueryString["AgeTo"])
                : model.AgeTo;

            UserAccountDetail uad;
            if (_mu != null)
            {
                if (!isAjax)
                {
                    uad = new UserAccountDetail();
                    uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey));

                    if (!string.IsNullOrWhiteSpace(Request.QueryString.ToString()))
                    {
                        uad.FindUserFilter = Request.QueryString.ToString();
                        uad.Update();
                    }
                    else if (!string.IsNullOrWhiteSpace(uad.FindUserFilter))
                    {
                        Response.Redirect(string.Format("~/findusers?{0}", uad.FindUserFilter));
                    }
                }
            }

            model.InterestedInID =
                (Request.QueryString["InterestedInID"] != null && Request.QueryString["InterestedInID"] == string.Empty)
                    ? null
                    : (Request.QueryString["InterestedInID"] == null)
                        ? model.InterestedInID
                        : Convert.ToInt32(Request.QueryString["InterestedInID"]);

            model.RelationshipStatusID =
                (Request.QueryString["RelationshipStatusID"] != null &&
                 Request.QueryString["RelationshipStatusID"] == string.Empty)
                    ? null
                    : (Request.QueryString["RelationshipStatusID"] == null)
                        ? model.RelationshipStatusID
                        : Convert.ToInt32(Request.QueryString["RelationshipStatusID"]);

            model.YouAreID =
                (Request.QueryString["YouAreID"] != null && Request.QueryString["YouAreID"] == string.Empty)
                    ? null
                    : (Request.QueryString["YouAreID"] == null)
                        ? model.YouAreID
                        : Convert.ToInt32(Request.QueryString["YouAreID"]);

            model.Lang = (Request.QueryString["lang"] != null && Request.QueryString["lang"] == string.Empty)
                ? null
                : Request.QueryString["lang"] ?? model.Lang;

            model.PostalCode
                = (Request.QueryString["postalcode"] != null && Request.QueryString["postalcode"] == string.Empty)
                    ? null
                    : Request.QueryString["postalcode"] ?? model.PostalCode;

            model.Country
                = (Request.QueryString["country"] != null && Request.QueryString["country"] == string.Empty)
                    ? null
                    : Request.QueryString["country"] ?? model.Country;

            _uas = new UserAccounts();

            bool sortByDistance;

            _uas.GetListUsers(_userPageNumber, PageSize, model.AgeFrom, model.AgeTo, model.InterestedInID,
                model.RelationshipStatusID,
                model.YouAreID, model.Country, model.PostalCode, model.Lang, out sortByDistance);

            if (!isAjax)
            {
                ViewBag.SortByDistance = sortByDistance;
            }

            if (_mu == null || isAjax) return;
            if (string.IsNullOrWhiteSpace(Request.QueryString.ToString())) return;
            uad = new UserAccountDetail();
            uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey));

            uad.FindUserFilter = Request.QueryString.ToString();
            uad.Update();
        }