Example #1
0
        public async Task <IHttpActionResult> Get()
        {
            IndentDTOPage singleIndentPageInfo = await _indentService.GetIndentsPerPage(1, 5, null);

            var indents = singleIndentPageInfo.IndentsOnPage;

            if (indents != null)
            {
                return(Ok(indents));
            }

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

            List <Category> categoriesInEnumEquivalent = null;

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

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

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

            IndentDTOPage indentsDTOSinglePageModel = await _indentService.GetIndentsPerPage(currentPageIndex,
                                                                                             pageSize, categoriesInEnumEquivalent);

            IndentPageViewModel indentPageViewModel = new IndentPageViewModel();

            indentPageViewModel = _mapper.Map <IndentPageViewModel>(indentsDTOSinglePageModel);
            indentPageViewModel.AvailableCategories = categories;

            return(View(indentPageViewModel));
        }