示例#1
0
        public async Task <IActionResult> Index(int?id, int?CategoryParentId, LayoutModel layoutModel)
        {
            try
            {
                var categoryModels = await categoryLogic.FindAsync
                                     (
                    id : id ?? 0,
                    categoryParentId : CategoryParentId ?? 0,
                    value : layoutModel.SearchValue,
                    mediaFolderPath : configuration["MediaFolderPath"],
                    withDisabled : User.FindFirst(ClaimTypes.Role).Value == RoleOptions.Librarian.ToString(),
                    orderBy : x => x.Name,
                    pageIndex : layoutModel.PageIndex,
                    pageSize : layoutModel.PageSize
                                     );

                var pageListModel = new PageListModel <CategoryModel>
                                    (
                    categoryModels,
                    layoutModel.ReturnUrl ?? currentUrl,
                    layoutModel.SearchValue,
                    layoutModel.PageIndex,
                    layoutModel.PageSize,
                    await suggestionLogic.UnReadCountAsync(),
                    await suggestionLogic.TopSuggestions(int.Parse(configuration["DashboardTopSuggestionLimit"]), configuration["MediaFolderPath"]),
                    Text.Searh_a_category,
                    "Index",
                    "Category"
                                    );

                if (IsAjax)
                {
                    return(PartialView("_IndexPartial", categoryModels));
                }
                return(View(pageListModel));
            }
            catch (Exception ex)
            {
                loggerFactory.CreateLogger(ex.GetType()).LogError($"{ex}\n\n");
                TempData["MessageType"] = MessageOptions.Warning;
                TempData["Message"]     = Text.An_error_occured;
            }
            return(RedirectToAction("Index", "Home"));
        }