Beispiel #1
0
        public async Task <ActionResult> ShowExecutorsPerPage(int?page, string[] categories)
        {
            int pageSize         = 4;
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            List <Category> categoriesInEnumEquivalent = null;

            if (categories != null)
            {
                List <string> categoriesCopy = new List <string>(categories);

                if (Session["Language"] != null)
                {
                    string lan = Session["Language"].ToString();

                    if (lan == "en")
                    {
                        categoriesInEnumEquivalent = CategoryExtension.
                                                     TranslateFromEnglishToEnumEquivalents(categoriesCopy.ToArray());
                    }
                    else
                    {
                        categoriesInEnumEquivalent = CategoryExtension.
                                                     TranslateFromRussianToEnumEquivalents(categoriesCopy.ToArray());
                    }
                }
            }

            ExecutorDTOPage executorsDTOSinglePageModel = await _executorService.GetExecutorsPerPage(currentPageIndex, pageSize,
                                                                                                     categoriesInEnumEquivalent);

            ExecutorPageViewModel executorPageViewModel = new ExecutorPageViewModel();

            executorPageViewModel = _mapper.Map <ExecutorPageViewModel>(executorsDTOSinglePageModel);
            executorPageViewModel.AvailableCategories = categories;

            return(View(executorPageViewModel));
        }