public async Task <IActionResult> Index(LayoutModel layoutModel)
        {
            try
            {
                var suggestionModels = await suggestionLogic.FindAsync
                                       (
                    value : layoutModel.SearchValue,
                    mediaFolderPath : configuration["MediaFolderPath"],
                    userId : (User.FindFirst(ClaimTypes.Role).Value != RoleOptions.Librarian.ToString() &&
                              User.FindFirst(ClaimTypes.Role).Value != RoleOptions.Admin.ToString())?(int?)int.Parse(User.Claims.FirstOrDefault(x => x.Type == "User.Id")?.Value ?? "0") : null,
                    orderBy : null,
                    orderByDescending : x => x.Date,
                    pageIndex : layoutModel.PageIndex,
                    pageSize : layoutModel.PageSize
                                       );

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

                if (IsAjax)
                {
                    return(PartialView("_IndexPartial", suggestionModels));
                }
                return(View(pageListModel));
            }
            catch (Exception ex)
            {
                loggerFactory.CreateLogger(ex.GetType()).LogError($"{ex}\n\n");
                TempData["MessageType"] = MessageOptions.Danger;
                TempData["Message"]     = Text.An_error_occured;
            }
            return(RedirectToAction("Index", "Home"));
        }
Пример #2
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"));
        }
        public async Task <IActionResult> Index(string categoryName, string documentIds, LayoutModel layoutModel)
        {
            try
            {
                ViewBag.SearchCategoryName = categoryName;
                var documentModels = await documentLogic.FindAsync
                                     (
                    documentIds : documentIds?.Split(',').Where(x => int.TryParse(x, out _)).Select(x => int.Parse(x)).ToArray(),
                    value : layoutModel.SearchValue,
                    mediaFolderPath : configuration["MediaFolderPath"],
                    withDisabled : User.FindFirst(ClaimTypes.Role).Value == RoleOptions.Librarian.ToString(),
                    orderBy : null,
                    orderByDescending : x => x.CreateDate,
                    pageIndex : layoutModel.PageIndex,
                    pageSize : layoutModel.PageSize
                                     );

                var pageListModel = new PageListModel <DocumentModel>
                                    (
                    documentModels,
                    layoutModel.ReturnUrl ?? currentUrl,
                    layoutModel.SearchValue,
                    layoutModel.PageIndex,
                    layoutModel.PageSize,
                    await suggestionLogic.UnReadCountAsync(),
                    await suggestionLogic.TopSuggestions(int.Parse(configuration["DashboardTopSuggestionLimit"]), configuration["MediaFolderPath"])
                                    );

                if (IsAjax)
                {
                    return(PartialView("_IndexPartial", documentModels));
                }
                return(View(pageListModel));
            }
            catch (Exception ex)
            {
                loggerFactory.CreateLogger(ex.GetType()).LogError($"{ex}\n\n");
                TempData["MessageType"] = MessageOptions.Danger;
                TempData["Message"]     = Text.An_error_occured;
            }
            return(RedirectToAction("Index", "Home"));
        }
Пример #4
0
        public async Task Refresh(ISuggestionLogic suggestionLogic, int limit, string mdiaFolderPath)
        {
            UnReadedSuggestionCount = await suggestionLogic.UnReadCountAsync();

            SuggestionModels = await suggestionLogic.TopSuggestions(limit, mdiaFolderPath);
        }