public JsonResult GetPopUpWindowsConfigById() { var model = BeautyHomePageConfigManager.GetBeautyPopUpWindowsConfigById(PKID) ?? new BeautyPopUpWindowsConfig() { Channel = "ios" }; var categorys = BeautyHomePageConfigManager.GetBeautyCategoryByChannel(model.Channel); List <PromotionInfoModel> promotions = new List <PromotionInfoModel>(); if (!string.IsNullOrEmpty(model.PromotionInfo)) { promotions = JsonConvert.DeserializeObject <List <PromotionInfoModel> >(model.PromotionInfo); } List <BeautyPopUpWindowsRegionModel> regions = new List <BeautyPopUpWindowsRegionModel>(); if (model.IsRegion && model.PKID > 0) { regions = BeautyHomePageConfigManager.GetBeautyPopUpWindowsRegionConfigs(model.PKID)?.ToList(); } return(Json(new { result = model, CategoryList = categorys, PromotionList = promotions, RegionList = regions })); }
public JsonResult GetPopUpWindowsConfigList() { int count = 0; var list = BeautyHomePageConfigManager.SelectBeautyPopUpConfig(Status, KeyWords, CurrentPage, PageSize, out count)?.ToList(); Dictionary <string, List <BeautyCategorySimple> > dic = new Dictionary <string, List <BeautyCategorySimple> >(); list.Select(s => s.Channel).Distinct().ForEach(f => { if (!dic.ContainsKey(f)) { var categorys = BeautyHomePageConfigManager.GetBeautyCategoryByChannel(f)?.ToList(); if (categorys != null && categorys.Any()) { dic.Add(f, categorys); } } }); list.ForEach(f => { if (!string.IsNullOrEmpty(f.Channel) && f.CategoryId > 0 && dic.ContainsKey(f.Channel)) { f.CategoryName = dic[f.Channel].FirstOrDefault(e => e.Id == f.CategoryId).Name; } }); return(Json(new { result = list, total = count }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetBeautyCategorysByChannel(string channel) { IEnumerable <BeautyCategorySimple> categorys = null; bool success = true; string msg = ""; try { categorys = BeautyHomePageConfigManager.GetBeautyCategoryByChannel(channel); } catch (Exception ex) { success = false; msg = ex.Message; } return(Json(new { Success = success, CategoryList = categorys, Msg = msg })); }