public ActionResult Circles(ParametrsForView parametrs)//+ { try { List <CirlceView> cirlces = new List <CirlceView>(); ParametrsForViewBll pBll = new ParametrsForViewBll() { Page = parametrs.Page, PageSize = Parametrs.PageSize, PartOfName = parametrs.PartOfName ?? "" }; int totalItems = _figuresService.GetCirclesCount(pBll); bool isPAgeActual = ((parametrs.Page - 1) * Parametrs.PageSize < totalItems); int updatedPage = isPAgeActual ? parametrs.Page : 1; pBll.Page = updatedPage; foreach (var item in _figuresService.GetAllCirlces(pBll)) { cirlces.Add(new CirlceView() { Id = item.Id, Name = item.Name, Radius = item.Radius }); } PagingInfoView pagingInfo = new PagingInfoView { CurrentPage = pBll.Page, ItemsPerPage = Parametrs.PageSize, TotalItems = totalItems }; CirlcesView c = new CirlcesView() { Cirlces = cirlces, PagingInfo = pagingInfo, }; return(View(c)); } catch (Exception ex) { return(HttpNotFound(ex.Message)); } }
public ActionResult Circles()//+ { try { ParametrsForView p = new ParametrsForView(); List <CirlceView> cirlces = new List <CirlceView>(); ParametrsForViewBll pBll = new ParametrsForViewBll() { Page = p.Page, PageSize = Parametrs.PageSize, PartOfName = p.PartOfName }; foreach (var item in _figuresService.GetAllCirlces(pBll)) { cirlces.Add(new CirlceView() { Id = item.Id, Name = item.Name, Radius = item.Radius }); } PagingInfoView pagingInfo = new PagingInfoView { CurrentPage = p.Page, ItemsPerPage = Parametrs.PageSize, TotalItems = _figuresService.GetCirclesCount(pBll) }; CirlcesView c = new CirlcesView() { Cirlces = cirlces, PagingInfo = pagingInfo, }; return(View(c)); } catch (Exception ex) { return(HttpNotFound(ex.Message)); } }