private void ApplyFilters(Models.Engine.AdvertismentsFilter filter, ref IQueryable <viewAdvertisment> advertisments) { if (filter == null) { throw new Exception("Advertisments filter is null"); } if (filter.OnlyWithPhotos) { advertisments = advertisments.Where(adv => adv.AdvertismentsPhotos.Any()); } if (!string.IsNullOrWhiteSpace(filter.Text)) { advertisments = advertisments.Where(adv => adv.text.Contains(filter.Text)); } if (filter.OnlyNew) { advertisments = advertisments.Where(adv => adv.CountByTextColumn == 1); } if (filter.NearUndeground) { advertisments = advertisments.Where(adv => adv.UndergroundStationID != null); } }
public ActionResult Section(string sectionUrl, string subpurchaseMode, [System.Web.Http.FromUri] Models.Engine.AdvertismentsFilter advertismentsFilter) { string _sectionName; int _sectionID; int? _subSectionID; string _date = Request["date"]; #region Section switch switch (sectionUrl) { case "Sdam-kvartiru": _sectionName = "Сдам квартиру"; _sectionID = 1; _subSectionID = 1; break; case "Snimu-kvartiru": _sectionName = "Сниму квартиру"; _sectionID = 1; _subSectionID = 2; break; case "Prodam-kvartiru": _sectionName = "Продам квартиру"; _sectionID = 3; _subSectionID = 3; break; case "Kuplu-kvartiru": _sectionName = "Куплю квартиру"; _sectionID = 3; _subSectionID = 4; break; case "Obyavleniya-Doma-Dachi": _sectionName = "Дома, дачи"; _sectionID = 6; _subSectionID = null; break; case "Arenda-ofisov": _sectionName = "Аренда офисов"; _sectionID = 4; _subSectionID = null; break; case "Prodam-kommercheskuu-nedvijimost": _sectionName = "Продажа коммерческой недвижимости"; _sectionID = 5; _subSectionID = null; break; default: _sectionName = "Сдам квартиру"; _sectionID = 1; _subSectionID = 1; break; } #endregion Section switch var advertisments = new SiteMVC.Models.Engine.AdvertismentsRequest() { SectionId = _sectionID, SubSectionId = _subSectionID, SectionName = _sectionName, Date = _date }; advertisments.Filter = advertismentsFilter; return(View(advertisments)); }
public ActionResult Index(string sectionUrl, string subSectionUrl, string subpurchaseMode, [System.Web.Http.FromUri] Models.Engine.AdvertismentsFilter advertismentsFilter, string city = null) { var result = new SiteMVC.ViewModels.Advertisments.AdvertismentsPageViewModel(); result.Request = new SiteMVC.Models.Engine.AdvertismentsRequest(); result.Request.Filter = advertismentsFilter; var dataModel = new DataModel(); var section = dataModel.AdvertismentSections .FirstOrDefault(s => s.friendlyUrl == sectionUrl); if (section == null) { throw new Exception("Not founded section with corresponded url."); } else { result.Request.SectionId = section.Id; result.Request.SectionName = section.displayName; result.SectionTitle = section.Title; result.SectionDescription = section.Description; result.SectionKeywords = section.Keywords; } var subSection = dataModel.AdvertismentSubSections .FirstOrDefault(s => s.friendlyUrl == subSectionUrl && s.AdvertismentSection_Id == section.Id); if (subSection == null) { result.Request.SubSectionId = null; } else { result.Request.SubSectionId = subSection.Id; if (!string.IsNullOrEmpty(subSection.displayName)) { result.Request.SectionName = subSection.displayName; } if (!string.IsNullOrEmpty(subSection.Title)) { result.SectionTitle = subSection.Title; } if (!string.IsNullOrEmpty(subSection.Description)) { result.SectionDescription = subSection.Description; } if (!string.IsNullOrEmpty(subSection.Keywords)) { result.SectionKeywords = subSection.Keywords; } } result.Request.State = State.NotSubpurchase; if (subpurchaseMode == Resources.Resource.VKLUCHAYA_POSREDNIKOV) { result.Request.State = State.SubpurchaseWithNotSubpurchase; } result.Request.Url = Request.RawUrl; result.Request.City = city; return(View(result)); }