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)); }
public async Task <IndentDTOPage> GetIndentsPerPage(int page, int pageSize, List <Category> categories) { List <int> categoriesValues = null; if (categories != null) { categoriesValues = new List <int>(); foreach (Category category in categories) { categoriesValues.Add((int)category); } } IndentPage indentsSinglePageModel = await _database.Indents.GetIndentsPerPage(page, pageSize, categoriesValues); IndentDTOPage indentsDTOSinglePageModel = _mapper.Map <IndentDTOPage>(indentsSinglePageModel); indentsDTOSinglePageModel.Page = ++page; indentsDTOSinglePageModel.PageSize = pageSize; return(indentsDTOSinglePageModel); }