Esempio n. 1
0
        public ActionResult ManageBars(ManageBarEditModel model, int pageIndex = 1)
        {
            pageResourceManager.InsertTitlePart("帖吧管理");

            //long userId = Request.QueryString.Gets<long>(model.UserId, new List<long>()).FirstOrDefault();

            BarSectionQuery query  = model.GetQuery();
            long            userId = Request.QueryString.Gets <long>("UserId", new List <long>()).FirstOrDefault();

            if (userId > 0)
            {
                query.UserId = userId;
            }
            ViewData["UserId"] = query.UserId;

            PagingDataSet <BarSection> sections = barSectionService.Gets(TenantTypeIds.Instance().Bar(), query, model.PageSize ?? 20, pageIndex);

            //为提升性能,批量获取吧主用户
            userService.GetFullUsers(sections.Select(n => n.UserId));
            ViewData["BarSections"] = sections;
            //foreach (var item in sections)
            //{
            //


            //    ViewData["BarSections-Category-" + item.SectionId] = categoryService.GetOwnerCategories(item.SectionId, TenantTypeIds.Instance().BarSection());
            //}



            PagingDataSet <Category> categories = categoryService.GetCategories(PubliclyAuditStatus.Success, TenantTypeIds.Instance().BarSection(), null, 1);



            ViewData["CategoryId"] = new SelectList(categories, "CategoryId", "CategoryName", model.CategoryId);


            //Dictionary<bool, string> enabledValues = new Dictionary<bool, string> { { true, "是" }, { false, "否" } };
            //ViewData["Enabled"] = new SelectList(enabledValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", model.Enabled);



            List <SelectListItem> enabledSelectLists = new List <SelectListItem> {
                new SelectListItem {
                    Text = "是", Value = true.ToString()
                },
                new SelectListItem {
                    Text = "否", Value = false.ToString()
                }
            };

            ViewData["Enabled"] = new SelectList(enabledSelectLists, "Value", "Text", model.Enabled);
            return(View(model));
        }
        public ActionResult ManageBars(ManageBarEditModel model, int pageIndex = 1)
        {
            pageResourceManager.InsertTitlePart("帖吧管理");

            //long userId = Request.QueryString.Gets<long>(model.UserId, new List<long>()).FirstOrDefault();

            BarSectionQuery query = model.GetQuery();
            long userId = Request.QueryString.Gets<long>("UserId", new List<long>()).FirstOrDefault();
            if (userId > 0)
                query.UserId = userId;
            ViewData["UserId"] = query.UserId;

            PagingDataSet<BarSection> sections = barSectionService.Gets(TenantTypeIds.Instance().Bar(), query, model.PageSize ?? 20, pageIndex);
            //为提升性能,批量获取吧主用户
            userService.GetFullUsers(sections.Select(n => n.UserId));
            ViewData["BarSections"] = sections;
            //foreach (var item in sections)
            //{
            //

            //    ViewData["BarSections-Category-" + item.SectionId] = categoryService.GetOwnerCategories(item.SectionId, TenantTypeIds.Instance().BarSection());
            //}

            PagingDataSet<Category> categories = categoryService.GetCategories(PubliclyAuditStatus.Success, TenantTypeIds.Instance().BarSection(), null, 1);

            ViewData["CategoryId"] = new SelectList(categories, "CategoryId", "CategoryName", model.CategoryId);

            //Dictionary<bool, string> enabledValues = new Dictionary<bool, string> { { true, "是" }, { false, "否" } };
            //ViewData["Enabled"] = new SelectList(enabledValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", model.Enabled);

            List<SelectListItem> enabledSelectLists = new List<SelectListItem> {
                 new SelectListItem{ Text="是",Value=true.ToString()},
                 new SelectListItem{ Text="否",Value=false.ToString()}
            };
            ViewData["Enabled"] = new SelectList(enabledSelectLists, "Value", "Text", model.Enabled);
            return View(model);
        }