コード例 #1
0
        public PartialViewResult AdvancedSearchBox()
        {
            SelectList sl = null;
            var model = new QuickTabSearchModel();
            var propertyTypes = from s in _db.PropertyTypes
                                where s.Id != 8
                                select new { id = s.Id, value = s.PropertyTypeName };
            sl = new SelectList(propertyTypes, "id", "value");
            model.propertyType = sl;

            var cities = from s in _db.Cities
                         select new { id = s.Id, value = s.CityName };
            sl = new SelectList(cities, "id", "value");
            model.cities = sl;

            var currecy = from s in _db.CurrencyTypes
                          select new { id = s.Id, value = s.CurrencyTypeName };
            sl = new SelectList(currecy, "id", "value");
            model.currecy = sl;

            return PartialView(model);

        }
コード例 #2
0
        //TODO добавить кеширование к данному методу
        public PartialViewResult QuickTabSearch()
        {
            SelectList sl = null;
            var model = new QuickTabSearchModel();

            var propertyTypes = (from s in _db.PropertyTypes
                                 select s.PropertyTypeName).ToList<string>();

            foreach (var item in propertyTypes)
            {
                int? key = (from s in _db.PropertyTypes
                            where s.PropertyTypeName == item
                            select s.Id).SingleOrDefault<int>();
                if (key != null && key > 0)
                {
                    var propertyActions = from s in _db.PropertyActions.AsQueryable()
                                          where s.PropertyType.Id == key
                                          select new { id = s.Id, value = s.PropertyActionName };
                    sl = new SelectList(propertyActions, "id", "value");

                    if (item == PropertyTypeEnum.flat.GetStringValue())
                        model.flatPropertyActions = sl;
                    else if (item == PropertyTypeEnum.commercialProperty.GetStringValue())
                        model.commercialPropertyAction = sl;
                    else if (item == PropertyTypeEnum.foreignProperty.GetStringValue())
                        model.foreignPropertyAction = sl;
                    else if (item == PropertyTypeEnum.houses.GetStringValue())
                        model.housesPropertyAction = sl;
                    else if (item == PropertyTypeEnum.land.GetStringValue())
                        model.landPropertyAction = sl;
                    else if (item == PropertyTypeEnum.parkingGarage.GetStringValue())
                        model.parkingGaragePropertyAction = sl;
                    else if (item == PropertyTypeEnum.services.GetStringValue())
                        model.servicesPropertyAction = sl;
                }
            }

            var cities = from s in _db.Cities
                         select new { id = s.Id, value = s.CityName };
            sl = new SelectList(cities, "id", "value");
            model.cities = sl;

            return PartialView(model);
        }