Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is V1PaymentItemDetail other &&
                   ((CategoryName == null && other.CategoryName == null) || (CategoryName?.Equals(other.CategoryName) == true)) &&
                   ((Sku == null && other.Sku == null) || (Sku?.Equals(other.Sku) == true)) &&
                   ((ItemId == null && other.ItemId == null) || (ItemId?.Equals(other.ItemId) == true)) &&
                   ((ItemVariationId == null && other.ItemVariationId == null) || (ItemVariationId?.Equals(other.ItemVariationId) == true)));
        }
        /// <summary>
        /// View model that attaches the items to their respective category
        /// </summary>
        /// <param name="category">The current category to have items assigned to</param>
        /// <param name="itemList">The list of items obtained from the exd file</param>
        public CategoryViewModel(string category, ObservableCollection <ItemData> itemList) : base(null, false)
        {
            _category = category;
            _itemList = itemList;

            IEnumerable <ItemData> filteredItems;

            //for aesthetic purposes the items in the character and pets category are not sorted by name
            if (!CategoryName.Equals(Strings.Character) && !CategoryName.Equals(Strings.Pets))
            {
                filteredItems = from item in _itemList where item.ItemCategory.Equals(Info.IDSlot[CategoryName]) orderby item.ItemName select item;
            }
            else
            {
                filteredItems = from item in _itemList where item.ItemCategory.Equals(Info.IDSlot[CategoryName]) select item;
            }

            foreach (ItemData item in filteredItems)
            {
                Children.Add(new ItemViewModel(item, this));
            }
        }
Esempio n. 3
0
        public override void ParseFromNetworkMessage(NetworkMessage message)
        {
            CategoryName   = message.ReadString();
            DisplayOfferId = message.ReadUInt32();
            WindowType     = message.ReadByte();

            Collections.Capacity = message.ReadByte();
            for (var i = 0; i < Collections.Capacity; ++i)
            {
                Collections.Add(message.ReadString());
            }

            if (Client.VersionNumber >= 11900000)
            {
                DisplaySubCategory = message.ReadString();
            }

            Offers.Capacity = message.ReadUInt16();
            for (var i = 0; i < Offers.Capacity; ++i)
            {
                var offer = new Offer
                {
                    Name       = message.ReadString(),
                    IsFeatured = WindowType == 3
                };

                offer.Details.Capacity = message.ReadByte();
                for (var j = 0; j < offer.Details.Capacity; ++j)
                {
                    var details = new OfferDetails
                    {
                        Id     = message.ReadUInt32(),
                        Amount = message.ReadUInt16(),
                        Price  = message.ReadUInt32()
                    };

                    if (Client.VersionNumber >= 11900000)
                    {
                        details.IsConfirmedPrice = message.ReadBool();
                    }

                    details.IsDisabled = message.ReadBool();
                    if (details.IsDisabled)
                    {
                        details.DisabledReasons.Capacity = message.ReadByte();
                        for (var x = 0; x < details.DisabledReasons.Capacity; ++x)
                        {
                            var disabledReason = message.ReadString();
                            details.DisabledReasons.Add(disabledReason);
                        }
                    }

                    details.HighlightState = message.ReadByte();
                    if (details.HighlightState == (int)StoreOfferHighlightState.Sale)
                    {
                        // This may actually be wrong, but since there aren't currently
                        // any items on sale I can't confirm it.
                        var saleValidUntilTimestamp = message.ReadUInt32();
                        var basePrice = message.ReadUInt32();
                    }

                    offer.Details.Add(details);
                }

                offer.DisplayType = message.ReadByte();
                if (offer.DisplayType == 0) // image (.png)
                {
                    offer.DisplayImage = message.ReadString();
                }
                else if (offer.DisplayType == 1) // mount id
                {
                    offer.DisplayMountId = message.ReadUInt16();
                }
                else if (offer.DisplayType == 2) // outfit
                {
                    offer.DisplayLooktype    = message.ReadUInt16();
                    offer.DisplayColorHead   = message.ReadByte();
                    offer.DisplayColorTorso  = message.ReadByte();
                    offer.DisplayColorLegs   = message.ReadByte();
                    offer.DisplayColorDetail = message.ReadByte();
                }
                else if (offer.DisplayType == 3) // item id
                {
                    offer.DisplayItemId = message.ReadUInt16();
                }
                else if (offer.DisplayType == 4) // male/female outfit
                {
                    offer.GenderToShow          = message.ReadByte();
                    offer.DisplayFemaleLooktype = message.ReadUInt16();
                    offer.DisplayMaleLooktype   = message.ReadUInt16();
                    offer.DisplayColorHead      = message.ReadByte();
                    offer.DisplayColorTorso     = message.ReadByte();
                    offer.DisplayColorLegs      = message.ReadByte();
                    offer.DisplayColorDetail    = message.ReadByte();
                }

                offer.TryType           = message.ReadByte(); // 0 = disabled, 1 = mounts/outfits, 2 = hireling dresses
                offer.Collection        = message.ReadString();
                offer.PopularityScore   = message.ReadUInt16();
                offer.NewUntilTimestamp = message.ReadUInt32();
                offer.NeedsUserConfigurationBeforeBuying = message.ReadBool();

                offer.Products.Capacity = message.ReadUInt16();
                for (var j = 0; j < offer.Products.Capacity; ++j)
                {
                    var subOffer = new Offer
                    {
                        Name        = message.ReadString(),
                        DisplayType = message.ReadByte()
                    };

                    if (subOffer.DisplayType == 0) // image (.png)
                    {
                        subOffer.DisplayImage = message.ReadString();
                    }
                    else if (subOffer.DisplayType == 1) // mount id
                    {
                        subOffer.DisplayMountId = message.ReadUInt16();
                    }
                    else if (subOffer.DisplayType == 2) // outfit
                    {
                        subOffer.DisplayLooktype    = message.ReadUInt16();
                        subOffer.DisplayColorHead   = message.ReadByte();
                        subOffer.DisplayColorTorso  = message.ReadByte();
                        subOffer.DisplayColorLegs   = message.ReadByte();
                        subOffer.DisplayColorDetail = message.ReadByte();
                    }
                    else if (subOffer.DisplayType == 3) // item sprite
                    {
                        subOffer.DisplayItemId = message.ReadUInt16();
                    }
                    else if (subOffer.DisplayType == 4) // male/female outfit
                    {
                        subOffer.GenderToShow          = message.ReadByte();
                        subOffer.DisplayFemaleLooktype = message.ReadUInt16();
                        subOffer.DisplayMaleLooktype   = message.ReadUInt16();
                        subOffer.DisplayColorHead      = message.ReadByte();
                        subOffer.DisplayColorTorso     = message.ReadByte();
                        subOffer.DisplayColorLegs      = message.ReadByte();
                        subOffer.DisplayColorDetail    = message.ReadByte();
                    }
                    offer.Products.Add(subOffer);
                }
                Offers.Add(offer);
            }

            if (CategoryName.Equals("Search", StringComparison.CurrentCultureIgnoreCase))
            {
                TooManySearchResults = message.ReadBool();
            }

            if (WindowType == 3) // Home
            {
                Banners.Capacity = message.ReadByte();
                for (var i = 0; i < Banners.Capacity; ++i)
                {
                    var banner = new Banner
                    {
                        Image = message.ReadString(),
                        Type  = message.ReadByte()
                    };

                    if (banner.Type == 2)
                    {
                        banner.Category   = message.ReadString();
                        banner.Collection = message.ReadString();
                    }
                    else if (banner.Type == 4)
                    {
                        banner.OfferId = message.ReadUInt32();
                    }

                    banner.Unknown = message.ReadUInt16(); // Always 0x0200 (512)?
                    Banners.Add(banner);
                }
                BannerSwitchDelay = message.ReadByte();
            }
        }
Esempio n. 4
0
        public override void AppendToNetworkMessage(NetworkMessage message)
        {
            message.Write((byte)ServerPacketType.StoreOffers);
            message.Write(CategoryName);
            message.Write(DisplayOfferId);
            message.Write(WindowType);

            var count = Math.Min(Collections.Count, byte.MaxValue);

            message.Write((byte)count);
            for (var i = 0; i < count; ++i)
            {
                message.Write(Collections[i]);
            }

            if (Client.VersionNumber >= 11900000)
            {
                message.Write(DisplaySubCategory);
            }

            count = Math.Min(Offers.Count, ushort.MaxValue);
            message.Write((ushort)count);
            for (var i = 0; i < count; ++i)
            {
                var offer = Offers[i];
                message.Write(offer.Name);

                var detailCount = Math.Min(offer.Details.Count, byte.MaxValue);
                message.Write((byte)detailCount);
                for (var j = 0; j < detailCount; ++j)
                {
                    var details = offer.Details[j];
                    message.Write(details.Id);
                    message.Write(details.Amount);
                    message.Write(details.Price);
                    if (Client.VersionNumber >= 11900000)
                    {
                        message.Write(details.IsConfirmedPrice);
                    }
                    message.Write(details.IsDisabled);
                    if (details.IsDisabled)
                    {
                        var reasonCount = Math.Min(details.DisabledReasons.Count, byte.MaxValue);
                        message.Write((byte)reasonCount);
                        for (var x = 0; x < reasonCount; ++x)
                        {
                            message.Write(details.DisabledReasons[x]);
                        }
                    }
                    message.Write(details.HighlightState);
                }

                message.Write(offer.DisplayType);
                if (offer.DisplayType == 0) // image (.png)
                {
                    message.Write(offer.DisplayImage);
                }
                else if (offer.DisplayType == 1) // mount id
                {
                    message.Write(offer.DisplayMountId);
                }
                else if (offer.DisplayType == 2) // outfit
                {
                    message.Write(offer.DisplayLooktype);
                    message.Write(offer.DisplayColorHead);
                    message.Write(offer.DisplayColorTorso);
                    message.Write(offer.DisplayColorLegs);
                    message.Write(offer.DisplayColorDetail);
                }
                else if (offer.DisplayType == 3) // item id
                {
                    message.Write(offer.DisplayItemId);
                }
                else if (offer.DisplayType == 4) // male/female outfit
                {
                    message.Write(offer.GenderToShow);
                    message.Write(offer.DisplayFemaleLooktype);
                    message.Write(offer.DisplayMaleLooktype);
                    message.Write(offer.DisplayColorHead);
                    message.Write(offer.DisplayColorTorso);
                    message.Write(offer.DisplayColorLegs);
                    message.Write(offer.DisplayColorDetail);
                }

                message.Write(offer.TryType);
                message.Write(offer.Collection);
                message.Write(offer.PopularityScore);
                message.Write(offer.NewUntilTimestamp);
                message.Write(offer.NeedsUserConfigurationBeforeBuying);

                var productCount = Math.Min(offer.Products.Count, ushort.MaxValue);
                message.Write((ushort)productCount);
                for (var j = 0; j < productCount; ++j)
                {
                    var subOffer = offer.Products[j];
                    message.Write(subOffer.Name);
                    message.Write(subOffer.DisplayType);
                    if (subOffer.DisplayType == 0) // image (.png)
                    {
                        message.Write(subOffer.DisplayImage);
                    }
                    else if (subOffer.DisplayType == 1) // mount id
                    {
                        message.Write(subOffer.DisplayMountId);
                    }
                    else if (subOffer.DisplayType == 2) // outfit
                    {
                        message.Write(subOffer.DisplayLooktype);
                        message.Write(subOffer.DisplayColorHead);
                        message.Write(subOffer.DisplayColorTorso);
                        message.Write(subOffer.DisplayColorLegs);
                        message.Write(subOffer.DisplayColorDetail);
                    }
                    else if (subOffer.DisplayType == 3) // item id
                    {
                        message.Write(subOffer.DisplayItemId);
                    }
                    else if (subOffer.DisplayType == 4) // male/female outfit
                    {
                        message.Write(subOffer.GenderToShow);
                        message.Write(subOffer.DisplayFemaleLooktype);
                        message.Write(subOffer.DisplayMaleLooktype);
                        message.Write(subOffer.DisplayColorHead);
                        message.Write(subOffer.DisplayColorTorso);
                        message.Write(subOffer.DisplayColorLegs);
                        message.Write(subOffer.DisplayColorDetail);
                    }
                }
            }

            if (CategoryName.Equals("Search", StringComparison.CurrentCultureIgnoreCase))
            {
                message.Write(TooManySearchResults);
            }

            if (WindowType == 3) // Home
            {
                count = Math.Min(Banners.Count, byte.MaxValue);
                message.Write((byte)count);
                for (var i = 0; i < count; ++i)
                {
                    var banner = Banners[i];
                    message.Write(banner.Image);
                    message.Write(banner.Type);
                    if (banner.Type == 2)
                    {
                        message.Write(banner.Category);
                        message.Write(banner.Collection);
                    }
                    else if (banner.Type == 4)
                    {
                        message.Write(banner.OfferId);
                    }
                    message.Write(banner.Unknown);
                }
                message.Write(BannerSwitchDelay);
            }
        }
Esempio n. 5
0
        public new void ConfigureForm(BaseApplicationManager m)
        {
            base.ConfigureForm(m);

            IEnumerable <MiscInfoNoId> tl;

            // Set radiobutton Ad Type
            if (CategoryName.Equals("Real Estate") || CategoryName.Equals("Jobs") || SubCategoryName.Equals("Pet Adoption") ||
                SubCategoryName.Equals("Pet & Animal Services") || SubCategoryName.Equals("Lost Pet") || CategoryName.Equals("Business Services"))
            {
                tl = m.GetAllAdTypes().Where(x => !x.Value.Equals("ALL") && !x.Value.Equals("TRADE")).ToList();
                // Rename
                if (SubCategoryName.Equals("Lost Pet"))
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Found";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Missing";
                }
                else if (CategoryName.Equals("Jobs"))
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Hiring (I am Hiring)";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Looking for (I am Looking For)";
                }
                else
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Offering (I am Selling)";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Looking For (I am Looking for)";
                }
            }
            else
            {
                tl = m.GetAllAdTypes().Where(x => !x.Value.Equals("ALL")).ToList();
                tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name  = "Offering (I am Selling)";
                tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name  = "Looking For (I am Looking for)";
                tl.SingleOrDefault(x => x.Value.Equals("TRADE")).Name = "Trading (I am Trading)";
            }
            SelectListForm.Add(new SelectListForm()
            {
                Name = "TypeList", List = new SelectList(tl, "Name", "Value")
            });
        }
Esempio n. 6
0
        /// <include file='doc\PerformanceCounterInstaller.uex' path='docs/doc[@for="PerformanceCounterInstaller.CopyFromComponent"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override void CopyFromComponent(IComponent component)
        {
            if (!(component is PerformanceCounter))
            {
                throw new ArgumentException(Res.GetString(Res.NotAPerformanceCounter));
            }

            PerformanceCounter counter = (PerformanceCounter)component;

            if (counter.CategoryName == null || counter.CategoryName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.IncompletePerformanceCounter));
            }

            if (Counters.Count > 0 && !CategoryName.Equals(counter.CategoryName))
            {
                throw new ArgumentException(Res.GetString(Res.NewCategory));
            }

            PerformanceCounterType counterType = PerformanceCounterType.NumberOfItems32;
            string counterHelp = string.Empty;

            if (CategoryName == null || string.Empty.Equals(CategoryName))
            {
                CategoryName = counter.CategoryName;
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    string machineName = counter.MachineName;

                    if (PerformanceCounterCategory.Exists(CategoryName, machineName))
                    {
                        string      keyPath = ServicePath + "\\" + CategoryName + "\\Performance";
                        RegistryKey key     = null;
                        try {
                            if (machineName == "." || String.Compare(machineName, SystemInformation.ComputerName, true, CultureInfo.InvariantCulture) == 0)
                            {
                                key = Registry.LocalMachine.OpenSubKey(keyPath);
                            }
                            else
                            {
                                RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "\\\\" + machineName);
                                key = baseKey.OpenSubKey(keyPath);
                            }

                            if (key == null)
                            {
                                throw new ArgumentException(Res.GetString(Res.NotCustomPerformanceCategory));
                            }

                            object systemDllName = key.GetValue("Library");
                            if (systemDllName == null || !(systemDllName is string) || String.Compare((string)systemDllName, PerfShimName, true, CultureInfo.InvariantCulture) != 0)
                            {
                                throw new ArgumentException(Res.GetString(Res.NotCustomPerformanceCategory));
                            }

                            PerformanceCounterCategory pcat = new PerformanceCounterCategory(CategoryName, machineName);
                            CategoryHelp = pcat.CategoryHelp;
                            if (pcat.CounterExists(counter.CounterName))
                            {
                                counterType = counter.CounterType;
                                counterHelp = counter.CounterHelp;
                            }
                        }
                        finally {
                            if (key != null)
                            {
                                key.Close();
                            }
                        }
                    }
                }
            }

            CounterCreationData data = new CounterCreationData(counter.CounterName, counterHelp, counterType);

            Counters.Add(data);
        }
Esempio n. 7
0
 public bool Equals(Feature f)
 {
     return(Name.Equals(f.Name) && CategoryName.Equals(f.CategoryName) && Count == f.Count);
 }
        public new void ConfigureForm(BaseApplicationManager m)
        {
            base.ConfigureForm(m);

            // Set Contact info from datastore
            string ucn = "", uce = "", ucp = "", ucp2 = "", ucp3 = "";

            m.SetContanctInfo(ref ucn, ref uce, ref ucp, ref ucp2, ref ucp3);
            AdContactName   = ucn;
            AdContactEmail  = uce;
            AdContactPhone  = ucp;
            AdContactPhone2 = ucp2;
            AdContactPhone3 = ucp3;
            IEnumerable <MiscInfoNoId> tl;

            // Set radiobutton Ad Type
            if (CategoryName.Equals("Real Estate") || CategoryName.Equals("Jobs") || SubCategoryName.Equals("Pet Adoption") ||
                SubCategoryName.Equals("Pet & Animal Services") || SubCategoryName.Equals("Lost Pet") || CategoryName.Equals("Business Services"))
            {
                tl = m.GetAllAdTypes().Where(x => !x.Value.Equals("ALL") && !x.Value.Equals("TRADE")).ToList();
                // Rename
                if (SubCategoryName.Equals("Lost Pet"))
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Found";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Missing";
                }
                else if (SubCategoryName.Equals("Pet Adoption"))
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Offering (I am Offering)";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Looking for (I am Looking For)";
                }
                else if (CategoryName.Equals("Jobs"))
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Hiring (I am Hiring)";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Looking for (I am Looking For)";
                }
                else
                {
                    tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name = "Offering (I am Selling)";
                    tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name = "Looking For (I am Looking for)";
                }
            }
            else
            {
                tl = m.GetAllAdTypes().Where(x => !x.Value.Equals("ALL")).ToList();
                tl.SingleOrDefault(x => x.Value.Equals("SELL")).Name  = "Offering (I am Selling)";
                tl.SingleOrDefault(x => x.Value.Equals("WANT")).Name  = "Looking For (I am Looking for)";
                tl.SingleOrDefault(x => x.Value.Equals("TRADE")).Name = "Trading (I am Trading)";
            }
            SelectListForm.Add(new SelectListForm()
            {
                Name = "TypeList", List = new SelectList(tl, "Name", "Value")
            });
        }
        public void ConfigureForm(BaseApplicationManager m)
        {
            if (SelectListForm == null)
            {
                SelectListForm = new List <SelectListForm>();
            }

            // Set Price Info (Saved values set in view)
            SelectListForm.Add(new SelectListForm()
            {
                Name = "PriceInfoList", List = new SelectList(m.GetAllPriceInfo(), "Value", "Value", (PriceInfo ?? null))
            });

            // populate select lists (Saved values set in view)
            SelectListForm.Add(new SelectListForm()
            {
                Name = "CountryList", List = new SelectList(m.GetAllCountries(), "Id", "Name", CountryId)
            });

            if (CountryId.HasValue)
            {
                var regions = m.GetAllRegionsByCountryId(CountryId.Value);
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "RegionList", List = new SelectList(regions, "Id", "Name", 0)
                });
            }
            else
            {
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "RegionList", List = new SelectList(Enumerable.Empty <SelectListItem>())
                });
            }

            // =======================
            if (SubCategoryName.Equals("Cars/Trucks"))
            {
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "MakeList", List = new SelectList(m.GetAllMake(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Make")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "BodyTypeList", List = new SelectList(m.BodyTypeGetAll(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Body Type")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "TransmissionList", List = new SelectList(m.GetAllTransmission(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Transmission")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "FuelTypeList", List = new SelectList(m.GetAllFuelType(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Fuel Type")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "ConditionList", List = new SelectList(m.GetAllCondition(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Condition")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "DrivetrainList", List = new SelectList(m.GetAllDrivetrain(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Drivetrain")).Description : null)
                });
            }
            else if (SubCategoryName.Equals("Motorcycles/ATVs"))
            {
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "MakeList", List = new SelectList(m.GetAllMake(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Make")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "FuelTypeList", List = new SelectList(m.GetAllFuelType(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Fuel Type")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "ConditionList", List = new SelectList(m.GetAllCondition(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Condition")).Description : null)
                });
            }
            else if (SubCategoryName.Equals("Automotive Parts"))
            {
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "MakeList", List = new SelectList(m.GetAllMake(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Make")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "ConditionList", List = new SelectList(m.GetAllCondition(), "Value", "Value", (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Condition")).Description : null)
                });
            }
            else if (CategoryName.Equals("Real Estate"))
            {
                if (SubCategoryName.Equals("Apartments/Condos Rental") || SubCategoryName.Equals("House Rental") || SubCategoryName.Equals("Land Rental/Leasing"))
                {
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "RentalType",
                        List = new SelectList(new List <string>()
                        {
                            "Rental Only",
                            "Rent To Own"
                        }, (AdInfo != null) ? AdInfo.DefaultIfEmpty(null).SingleOrDefault(x => x.Name.Equals("Rental Type")).Description : null)
                    });
                }

                if (SubCategoryName.Contains("Apartments/Condos") || SubCategoryName.Contains("House"))
                {
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "BedroomList",
                        List = new SelectList(new List <string>()
                        {
                            "Bachelor / Studio",
                            "1 bedroom",
                            "2 bedrooms",
                            "3 bedrooms",
                            "4 bedrooms",
                            "5 or more bedrooms"
                        }, (AdInfo != null) ? AdInfo.DefaultIfEmpty(null).SingleOrDefault(x => x.Name.Equals("Bedrooms")).Description : null)
                    });
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "BathroomList",
                        List = new SelectList(new List <string>()
                        {
                            "1 bathroom",
                            "2 bathrooms",
                            "3 bathrooms",
                            "4 bathrooms",
                            "5 or more bathrooms"
                        }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Bathrooms")).Description : null)
                    });
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "FurnishedList",
                        List = new SelectList(new List <string>()
                        {
                            "Unfurnished",
                            "Semi-Furnished",
                            "Fully-Furnished"
                        }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Furnished")).Description : null)
                    });
                }
                else if (SubCategoryName.Equals("Commercial Office Space"))
                {
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "FurnishedList",
                        List = new SelectList(new List <string>()
                        {
                            "Unfurnished",
                            "Semi-Furnished",
                            "Fully-Furnished"
                        }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Furnished")).Description : null)
                    });
                }
            }
            else if (CategoryName.Equals("Jobs"))
            {
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "JobTypeList",
                    List = new SelectList(new List <string>()
                    {
                        "Full-time",
                        "Permanent Full-time",
                        "Part-time",
                        "Permanent Part-time",
                        "Temporary",
                        "Contract",
                        "Internship",
                        "Project",
                        "Please Contact"
                    }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Job Type")).Description : null)
                });
                SelectListForm.Add(new SelectListForm()
                {
                    Name = "SalaryInfoList",
                    List = new SelectList(new List <string>()
                    {
                        "Hourly",
                        "Daily",
                        "Weekly",
                        "Fortnightly",
                        "Monthly",
                        "Yearly"
                    }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Salary Type")).Description : null)
                });
            }
            else if (CategoryName.Equals("Pets"))
            {
                if (SubCategoryName.Equals("Lost Pet") || SubCategoryName.Equals("Pet Adoption") || SubCategoryName.Equals("Pet Hub") || SubCategoryName.Equals("Pet Services") || SubCategoryName.Equals("Pet Accessories") || SubCategoryName.Equals("Pet & Animal Services"))
                {
                    SelectListForm.Add(new SelectListForm()
                    {
                        Name = "SpeciesList",
                        List = new SelectList(new List <string>()
                        {
                            "Bird",
                            "Cat",
                            "Dog",
                            "Fish",
                            "Other"
                        }, (AdInfo != null) ? AdInfo.SingleOrDefault(x => x.Name.Equals("Species")).Description : null)
                    });
                }
            }
            // Handles Create ad photo init
            if (Photos == null)
            {
                if (CategoryName.Equals("Jobs"))
                {
                    Photos = new UploadPhoto[1];
                }
                else if (SubCategoryName.Contains("Apartments/Condos") || SubCategoryName.Contains("House") || SubCategoryName.Contains("Office") || SubCategoryName.Contains("Cars/Trucks"))
                {
                    Photos = new UploadPhoto[12];
                }
                else
                {
                    Photos = new UploadPhoto[6];
                }
            }
        }
Esempio n. 10
0
        public new void ConfigureForm(BaseApplicationManager m)
        {
            CurrentPhotoCount = Photos.Length;
            if (Photos != null)
            {
                var temp = Photos;
                var max  = 0;
                if (CategoryName.Equals("Jobs"))
                {
                    max = 1;
                }
                else if (SubCategoryName.Contains("Apartments/Condos") || SubCategoryName.Contains("House") || SubCategoryName.Contains("Office") || SubCategoryName.Contains("Cars/Trucks"))
                {
                    max = 12;
                }
                else
                {
                    max = 6;
                }
                Photos = new UploadPhoto[max];
                for (int i = 0; i < max; i++)
                {
                    Photos[i] = _getPhoto(i, temp.Length, temp);
                }
            }
            base.ConfigureForm(m);
            try
            {
                var years = AdInfo.Where(x => x.Name.Equals("Year")).ToList();
                if (years != null && years.Count > 1)
                {
                    AdInfo.FirstOrDefault(x => x.Name.Equals("Year")).Description = years.FirstOrDefault().Description + "-" + years.LastOrDefault().Description;
                    foreach (var y in years)
                    {
                        if (y != years.FirstOrDefault())
                        {
                            AdInfo.Remove(y);
                        }
                    }
                }

                var ages = AdInfo.Where(x => x.Name.Equals("Age")).ToList();
                if (ages != null && ages.Count > 0)
                {
                    foreach (var a in ages)
                    {
                        if (a != ages.FirstOrDefault())
                        {
                            AdInfo.Remove(a);
                        }
                    }
                    if (ages.FirstOrDefault().Description != null)
                    {
                        AgeType = AdInfo.SingleOrDefault(x => x.Name.Equals("Age")).Description.Split(' ').Last();
                        AdInfo.SingleOrDefault(x => x.Name.Equals("Age")).Description = AdInfo.SingleOrDefault(x => x.Name.Equals("Age")).Description.Split(' ').First();
                    }
                }
                var ai = m.GetAdTemplate(SubCategoryId).Except(AdInfo, new CustomCompare()).ToList();
                AdInfo = AdInfo.Union(ai).ToList();
            }
            catch (Exception) { }
        }