/// <summary> /// 获取搜索条件列表 /// </summary> /// <param name="searchTrem"></param> /// <returns></returns> private List<HttpLinkGroup> GetSearch(ListSearchItemViewModel search) { List<HttpLinkGroup> result = new List<HttpLinkGroup>(); Dictionary<string, string> cacheDic = new Dictionary<string, string>(); cacheDic.Add(CacheService.ServiceName, "ListController"); cacheDic.Add(CacheService.ServiceMethod, "GetSearch"); cacheDic.Add("Province", search.Province); cacheDic.Add("City", search.City.ToString()); cacheDic.Add("MediaCode", search.MediaCode.ToString()); cacheDic.Add("ChildMediaCode", search.ChildMediaCode.ToString()); cacheDic.Add("FormatCode", search.FormatCode.ToString()); cacheDic.Add("OwnerCode", search.OwnerCode.ToString()); cacheDic.Add("PeriodCode", search.PeriodCode.ToString()); if (CacheService.Exists(cacheDic)) { result = CacheService.Get<List<HttpLinkGroup>>(cacheDic); } else { var provinceValue = EnumHelper.GetProvinceValue(search.Province); #region CityGroup if (provinceValue != (int)ProvinceName.quanguo) { HttpLinkGroup cityGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "城市", Url = Url.Action("index", new { province = search.Province, city = 0, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }) } }; cityGroup.Items = areaService.GetALL().Where(x => x.PID == provinceValue).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = x.ID, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }), Selected = x.ID == search.City }).ToList(); result.Add(cityGroup); } #endregion #region MediaCode HttpLinkGroup categoryGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "媒体类别", Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = 0, childmediacode = 0, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }) } }; categoryGroup.Items = outDoorMediaCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = x.ID, childmediacode = 0, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }), Selected = search.MediaCode == x.ID }).ToList(); result.Add(categoryGroup); #endregion #region ChildMediaCode if (search.MediaCode != 0) { HttpLinkGroup childCategoryGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "媒体子类别", Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = 0, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }) } }; childCategoryGroup.Items = outDoorMediaCateService.GetALL().Where(x => x.PID == search.MediaCode).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = x.ID, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = search.PeriodCode }), Selected = search.ChildMediaCode == x.ID }).ToList(); result.Add(childCategoryGroup); } #endregion #region FormatCode HttpLinkGroup formatGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "表现形式", Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = 0, ownercode = search.OwnerCode, periodcode = search.PeriodCode }) } }; formatGroup.Items = formatCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = x.ID, ownercode = search.OwnerCode, periodcode = search.PeriodCode }), Selected = search.FormatCode == x.ID }).ToList(); result.Add(formatGroup); #endregion #region OwnerCode HttpLinkGroup ownerGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "代理类型", Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = 0, periodcode = search.PeriodCode }) } }; ownerGroup.Items = ownerCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = x.ID, periodcode = search.PeriodCode }), Selected = search.OwnerCode == x.ID }).ToList(); result.Add(ownerGroup); #endregion #region PeriodCode HttpLinkGroup periodGroup = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "投放周期", Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = search.OwnerCode }) } }; periodGroup.Items = periodCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem() { ID = x.ID, Name = x.CateName, Url = Url.Action("index", new { province = search.Province, city = search.City, mediacode = search.MediaCode, childmediacode = search.ChildMediaCode, formatcode = search.FormatCode, ownercode = search.OwnerCode, periodcode = x.ID }), Selected = search.PeriodCode == x.ID }).ToList(); result.Add(periodGroup); #endregion CacheService.Add<List<HttpLinkGroup>>(result, cacheDic, 180); } return result; }
public List<HttpLinkGroup> GetProvinceList(int province) { List<HttpLinkGroup> result = new List<HttpLinkGroup>(); HttpLinkGroup quanguo = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "全国" } }; HttpLinkItem quanguoLink = new HttpLinkItem() { Name = "全国", ProvinceName = ProvinceName.quanguo.ToString() }; quanguo.Items.Add(quanguoLink); result.Add(quanguo); var provinceList = UIHelper.ProvinceList.Where(x => x.Value != "quanguo").OrderBy(x => x.Value).ToList(); foreach (var item in provinceList) { var prefix = item.Value.Substring(0, 1).ToUpper(); var groupItem = result.SingleOrDefault(x => x.Group.Name == prefix); if (groupItem == null) { groupItem = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = item.Value.Substring(0, 1).ToUpper() } }; result.Add(groupItem); } HttpLinkItem itemLink = new HttpLinkItem() { Name = item.Text, ProvinceName = item.Value }; groupItem.Items.Add(itemLink); } return result; }
private List<HttpLinkGroup> GetSliderTabBox(int province) { bool isQuanGuo = province == (int)ProvinceName.quanguo; List<HttpLinkGroup> result = new List<HttpLinkGroup>(); Dictionary<string, string> cacheDic = new Dictionary<string, string>(); cacheDic.Add(CacheService.ServiceName, "HomeController"); cacheDic.Add(CacheService.ServiceMethod, "GetSliderTabBox"); cacheDic.Add("province", province.ToString()); if (CacheService.Exists(cacheDic)) { result = CacheService.Get<List<HttpLinkGroup>>(cacheDic); } else { HttpLinkGroup group = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "推荐资源" } }; group.Items = sourceService.GetSuggestMedia(province, 8); result.Add(group); group = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "优质资源" } }; group.Items = sourceService.GetGoodMedia(province, 8); result.Add(group); group = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "认证资源" } }; group.Items = sourceService.GetAuthMedia(province, 8); result.Add(group); group = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "最新资源" } }; group.Items = sourceService.GetNewMedia(province, 8); result.Add(group); CacheService.Add<List<HttpLinkGroup>>(result, cacheDic, 60); } return result; }
/// <summary> /// 获取分类导航菜单数据 /// </summary> /// <returns></returns> public List<HttpLinkGroup> GetLeftMenu(int province) { List<HttpLinkGroup> result = new List<HttpLinkGroup>(); var category = outDoorMediaCateService.IncludeGetALL().ToList(); foreach (var item in category) { HttpLinkGroup groupItem = new HttpLinkGroup(); HttpLinkItem groupLink = new HttpLinkItem() { ID = item.ID, Name = item.CateName, Province = province }; groupItem.Group = groupLink; List<HttpLinkItem> items = item.ChildCategoies.Select(x => new HttpLinkItem { ID = x.ID, Name = x.CateName, Province = province, PCategoryCode = groupLink.ID, CategoryCode = x.ID }).ToList(); groupItem.Items = items; result.Add(groupItem); } return result; }
private List<HttpLinkGallery> GetGallery(int province, int take) { bool isQuanGuo = province == (int)ProvinceName.quanguo; List<HttpLinkGallery> result = new List<HttpLinkGallery>(); Dictionary<string, string> cacheDic = new Dictionary<string, string>(); cacheDic.Add(CacheService.ServiceName, "HomeController"); cacheDic.Add(CacheService.ServiceMethod, "GetGallery"); cacheDic.Add("province", province.ToString()); cacheDic.Add("take", take.ToString()); if (CacheService.Exists(cacheDic)) { result = CacheService.Get<List<HttpLinkGallery>>(cacheDic); } else { var categorys = outDoorMediaCateService.GetALL().Where(x => x.PID.Equals(null)).ToList(); foreach (var category in categorys) { HttpLinkGallery galleryContainer = new HttpLinkGallery() { Gallery = new HttpLinkItem() { ID = category.ID, Name = category.CateName } }; HttpLinkGroup tab = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "推荐资源" } }; tab.Items = sourceService.GetSuggestMedia(province, take, 0, category.ID); galleryContainer.Tabs.Add(tab); tab = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "优质资源" } }; tab.Items = sourceService.GetGoodMedia(province, take, 0, category.ID); galleryContainer.Tabs.Add(tab); tab = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "认证资源" } }; tab.Items = sourceService.GetAuthMedia(province, take, 0, category.ID); galleryContainer.Tabs.Add(tab); tab = new HttpLinkGroup() { Group = new HttpLinkItem() { Name = "最新资源" } }; tab.Items = sourceService.GetNewMedia(province, take, 0, category.ID); galleryContainer.Tabs.Add(tab); result.Add(galleryContainer); } CacheService.Add<List<HttpLinkGallery>>(result, cacheDic, 60); } return result; }