Exemple #1
0
        public virtual void FromNameValueCollection(NameValueCollection collection)
        {
            if (!string.IsNullOrEmpty(collection["OT"]))
            {
                ObjectType = Helper.GetObjectTypeNumericID(collection["OT"]);
            }
            if (!string.IsNullOrEmpty(collection["OTS"]))
            {
                ObjectType  = 0;
                ObjectTypes = QuickParameters.GetDelimitedObjectTypeIDs(collection["OTS"], ',');
            }
            string paramCtyId = string.Empty;

            if (collection["XCN"] != null)
            {
                paramCtyId = collection["XCN"];
            }
            else if (!string.IsNullOrEmpty(collection["CN"]))
            {
                paramCtyId = collection["CN"];
            }
            if (!string.IsNullOrEmpty(paramCtyId))
            {
                if (!paramCtyId.IsGuid())
                {
                    CommunityID = DataObjectCommunity.GetCommunityIDByVirtualURL(paramCtyId);
                }
                else
                {
                    CommunityID = paramCtyId.ToGuid();
                }
            }
            if (!string.IsNullOrEmpty(collection["CNS"]))
            {
                CommunityID = null;
                Communities = QuickParameters.GetDelimitedCommunityIDs(collection["CNS"], ',');
            }

            string paramUserId = string.Empty;

            if (collection["XUI"] != null)
            {
                paramUserId = collection["XUI"];
            }
            else if (!string.IsNullOrEmpty(collection["UI"]))
            {
                paramUserId = collection["UI"];
            }
            if (!string.IsNullOrEmpty(paramUserId))
            {
                if (!paramUserId.IsGuid())
                {
                    UserID = DataObjectUser.GetUserIDByNickname(paramUserId);
                }
                else
                {
                    UserID = paramUserId.ToGuid();
                }
            }

            if (!string.IsNullOrEmpty(collection["TG"]))
            {
                TagID = HttpUtility.UrlDecode(collection["TG"]).ToNullableGuid();
            }
            if (!string.IsNullOrEmpty(collection["TGL1"]))
            {
                TagID    = null;
                RawTags1 = collection["TGL1"];
                Tags1    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL1"]), ',');
            }
            if (!string.IsNullOrEmpty(collection["TGL2"]))
            {
                TagID    = null;
                RawTags2 = collection["TGL2"];
                Tags2    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL2"]), ',');
            }
            if (!string.IsNullOrEmpty(collection["TGL3"]))
            {
                TagID    = null;
                RawTags3 = collection["TGL3"];
                Tags3    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL3"]), ',');
            }

            if (!string.IsNullOrEmpty(collection["SO"]))
            {
                SortBy = (QuickSort)Enum.Parse(typeof(QuickSort), collection["SO"], true);
            }
            if (!string.IsNullOrEmpty(collection["SD"]))
            {
                Direction = (QuickSortDirection)Enum.Parse(typeof(QuickSortDirection), collection["SD"], true);
            }

            if (!string.IsNullOrEmpty(collection["SO2"]))
            {
                SortBySecond = (QuickSort)Enum.Parse(typeof(QuickSort), collection["SO2"], true);
            }
            if (!string.IsNullOrEmpty(collection["SD2"]))
            {
                DirectionSecond = (QuickSortDirection)Enum.Parse(typeof(QuickSortDirection), collection["SD2"], true);
            }

            if (!string.IsNullOrEmpty(collection["AM"]))
            {
                int temp;
                if (int.TryParse(collection["AM"], out temp))
                {
                    amount = temp;
                }
            }
            if (!string.IsNullOrEmpty(collection["PN"]))
            {
                int.TryParse(collection["PN"], out pageNumber);
            }
            if (!string.IsNullOrEmpty(collection["PS"]))
            {
                int.TryParse(collection["PS"], out pageSize);
                pageSize = Math.Min(pageSize, 100);
            }
            if (!string.IsNullOrEmpty(collection["SS"]))
            {
                ShowState = (ObjectShowState)Enum.Parse(typeof(ObjectShowState), collection["SS"], true);
            }
            if (!string.IsNullOrEmpty(collection["FI"]))
            {
                DateTime formInserted;
                if (DateTime.TryParse(collection["FI"], out formInserted))
                {
                    fromInserted = formInserted;
                }
            }
            if (!string.IsNullOrEmpty(collection["TI"]))
            {
                DateTime toInserted;
                if (DateTime.TryParse(collection["TI"], out toInserted))
                {
                    this.toInserted = toInserted;
                }
            }
            if (!string.IsNullOrEmpty(collection["FE"]))
            {
                int featured;
                if (int.TryParse(collection["FE"], out featured))
                {
                    this.featured = featured;
                }
            }
            if (!string.IsNullOrEmpty(collection["WC"]))
            {
                bool withCopy;
                if (bool.TryParse(collection["WC"], out withCopy))
                {
                    this.withCopy = withCopy;
                }
            }
            if (!string.IsNullOrEmpty(collection["FS"]))
            {
                DateTime fromStartDate;
                if (DateTime.TryParse(collection["FS"], out fromStartDate))
                {
                    this.fromStartDate = fromStartDate;
                }
            }
            if (!string.IsNullOrEmpty(collection["TS"]))
            {
                DateTime toEndDate;
                if (DateTime.TryParse(collection["TS"], out toEndDate))
                {
                    this.toEndDate = toEndDate;
                }
            }
            if (!string.IsNullOrEmpty(collection["TSD"]))
            {
                DateTime toStartDate;
                if (DateTime.TryParse(collection["TSD"], out toStartDate))
                {
                    this.toStartDate = toStartDate.GetStartOfDay();
                }
            }
            if (!string.IsNullOrEmpty(collection["FED"]))
            {
                DateTime fromEndDate;
                if (DateTime.TryParse(collection["FED"], out fromEndDate))
                {
                    this.fromEndDate = fromEndDate.GetEndOfDay();
                }
            }
            if (!string.IsNullOrEmpty(collection["DM"]))
            {
                DateQueryMethode = (QuickDateQueryMethode)Enum.Parse(typeof(QuickDateQueryMethode), collection["DM"], true);
            }
            if (!string.IsNullOrEmpty(collection["CO"]))
            {
                Country = collection["CO"];
            }
            if (!string.IsNullOrEmpty(collection["ZP"]))
            {
                Zip = collection["ZP"];
            }
            if (!string.IsNullOrEmpty(collection["CI"]))
            {
                City = HttpUtility.UrlDecode(collection["CI"]);
            }
            if (!string.IsNullOrEmpty(collection["GC"]))
            {
                string[] coordsList = collection["GC"].Split(new char[] { ',' });
                if (coordsList.Length == 2)
                {
                    GeoLat  = float.Parse(coordsList[0]);
                    GeoLong = float.Parse(coordsList[1]);
                }
            }
            if (!string.IsNullOrEmpty(collection["DI"]))
            {
                DistanceKm = float.Parse(collection["DI"]);
            }
            if (!string.IsNullOrEmpty(collection["OC"]))
            {
                bool onlyConverted;
                if (bool.TryParse(collection["OC"], out onlyConverted))
                {
                    this.onlyConverted = onlyConverted;
                }
            }
            if (!string.IsNullOrEmpty(collection["OI"]))
            {
                bool onlyWithImage;
                if (bool.TryParse(collection["OI"], out onlyWithImage))
                {
                    this.onlyWithImage = onlyWithImage;
                }
            }
            if (!string.IsNullOrEmpty(collection["NI"]))
            {
                Nickname = HttpUtility.UrlDecode(collection["NI"]);
            }
            if (!string.IsNullOrEmpty(collection["TL"]))
            {
                Title = HttpUtility.UrlDecode(collection["TL"]);
            }
            if (!string.IsNullOrEmpty(collection["DE"]))
            {
                Description = HttpUtility.UrlDecode(collection["DE"]);
            }
            if (!string.IsNullOrEmpty(collection["SU"]))
            {
                UserSearch = HttpUtility.UrlDecode(collection["SU"]);
            }
            if (!string.IsNullOrEmpty(collection["IG"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["IG"], out boolVal))
                {
                    IncludeGroups = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["IC"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["IC"], out boolVal))
                {
                    IgnoreCache = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["GT"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["GT"], out boolVal))
                {
                    OnlyGeoTagged = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["SG"]))
            {
                GeneralSearch = HttpUtility.UrlDecode(collection["SG"]);
            }

            if (!string.IsNullOrEmpty(collection["OID"]))
            {
                ObjectID = collection["OID"].ToGuid();
            }

            if (!string.IsNullOrEmpty(collection["COID"]))
            {
                CurrentObjectID = collection["COID"].ToGuid();
            }

            if (!string.IsNullOrEmpty(collection["RPID"]))
            {
                if (RelationParams == null)
                {
                    RelationParams = new RelationParams();
                }
                RelationParams.ParentObjectID = collection["RPID"].ToGuid();
            }
        }