Example #1
0
 public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions, object htmlAttributes)
 {
     if (pagedList == null)
         return AjaxPager(html, pagerOptions, new RouteValueDictionary(htmlAttributes));
     return AjaxPager(html, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null,
                      ajaxOptions, htmlAttributes);
 }
 public GalleryViewModel(Photoset set, IPagedList<FlickrNet.Photo> collection, int post, string id)
 {
     this.Photoset = set;
     this.Photos = collection;
     this.PostID = post;
     this.PhotosetID = id;
 }
Example #3
0
 public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     if (pagedList == null)
         return AjaxPager(html, pagerOptions, null);
     return AjaxPager(html, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions,
                      null);
 }
		public static AccountMyAuctionsViewModel FromAuctions(IPagedList<Auction> auctions,
		                                                      string titleFilter,
		                                                      int createdInDays,
		                                                      AuctionStatusFilter currentStatusFilter)
		{
			Contract.Requires(auctions != null);

			var items = auctions.Select(x => new AccountMyAuctionsViewModel.Item
			{
				Id           = x.Id,
				Title        = x.Title,
				CategoryName = x.Category.Name,
				CategoryId   = x.Category.Id,
				Status       = x.Status,
				TimeTillEnd  = x.EndDate - DateTime.Now,
				BuyoutPrice  = x.BuyoutPrice,
				BestOffer    = x.BestOffer != null ? x.BestOffer.Money : null
			});

			return new AccountMyAuctionsViewModel
			{
				Auctions            = new StaticPagedList<AccountMyAuctionsViewModel.Item>(items, auctions),
				TitleFilter         = titleFilter,
				CreatedIn           = TimeSpan.FromDays(createdInDays),
				CurrentStatusFilter = currentStatusFilter
			};
		}
Example #5
0
 /// <summary>
 /// Generates a digg-like pager - div with page numbers as links, previous and next links(or spans)
 /// </summary>
 /// <param name="htmlHelper">Instance of html helper</param>
 /// <param name="collection">Paged collection to render pager for</param>
 /// <param name="actionName">Action name for links generation (optional: default = null)</param>
 /// <param name="controllerName">Controller name for links generation (optional: default = null)</param>
 /// <param name="pagerHtmlAttributes">Object with html attributes for pager container</param>
 /// <param name="pagerContainer">Pager container (optional: default = "div")</param>
 /// <param name="previousLabel">Caption for previous label (optinoal: default = '« Previous')</param>
 /// <param name="nextLabel">Caption for next label (optional: default = 'Next »')</param>
 /// <param name="innerWindow">How many links are shown around current page (optional: default = 4)</param>
 /// <param name="outerWindow">How many links are shown around the first and the last pages (optional: default = 1)</param>
 /// <param name="separator">String separator between page links or spans (optional: default ' ' - space)</param>
 /// <param name="windowLinks">
 /// When true, 'next', 'previous' and page numbers should be rendered,
 /// when false, only 'next' and 'previous' should be rendered.
 /// Optional: default = true
 /// </param>
 /// <returns>System.Web.Mvc.MvcHtmlString</returns>
 public static MvcHtmlString Pager(
     this HtmlHelper htmlHelper,
     IPagedList collection,
     string actionName = null,
     string controllerName = null,
     object pagerHtmlAttributes = null,
     string pagerContainer = "div",
     string previousLabel = "&larr;",
     string nextLabel = "&rarr;",
     int innerWindow = 4,
     int outerWindow = 1,
     string separator = " ",
     bool windowLinks = true
     )
 {
     IRenderer renderer = new DiggStyleLinkRenderer {
         HtmlHelper = htmlHelper,
         Collection = collection,
         ActionName = actionName,
         ControllerName = controllerName,
         PagerContainer = pagerContainer,
         InnerWindow = innerWindow,
         NextLabel = nextLabel,
         OuterWindow = outerWindow,
         PreviousLabel = previousLabel,
         Separator = separator,
         WindowLinks = windowLinks
     };
     renderer.PagerHtmlAttributes = new RouteValueDictionary(pagerHtmlAttributes);
     return MvcHtmlString.Create(renderer.GenerateHtml());
 }
Example #6
0
        public static MvcHtmlString SeoPager(this HtmlHelper helper, IPagedList pagedList, string pageIndexParameterName = "id", int sectionSize = 20)
        {
            var sb = new StringBuilder();

            int pageCount = pagedList.TotalItemCount / pagedList.PageSize + (pagedList.TotalItemCount % pagedList.PageSize == 0 ? 0 : 1);

            if (pageCount > 1)
            {
                var pages = new List<int>();
                for (int i = 1; i <= pageCount; i++)
                    pages.Add(i);
                var sections = pages.GroupBy(p => (p - 1) / sectionSize);
                var currentSection = sections.Single(s => s.Key == (pagedList.CurrentPageIndex - 1) / sectionSize);
                foreach (var p in currentSection)
                {
                    if (p == pagedList.CurrentPageIndex)
                        sb.AppendFormat("<span>{0}</span>", p);
                    else
                        sb.AppendFormat("<a href=\"{1}\">{0}</a>", p, PrepearRouteUrl(helper, pageIndexParameterName, p));
                }
                if (sections.Count() > 1)
                {
                    sb.Append("<br/>");

                    foreach (var s in sections)
                    {
                        if (s.Key == currentSection.Key)
                            sb.AppendFormat("<span>{0}-{1}</span>", s.First(), s.Last());
                        else
                            sb.AppendFormat("<a href=\"{2}\">{0}-{1}</a>", s.First(), s.Last(), PrepearRouteUrl(helper, pageIndexParameterName, s.First()));
                    }
                }
            }
            return MvcHtmlString.Create(sb.ToString());
        }
        public static string BlogPager(this HtmlHelper helper, IPagedList pager)
        {
            // Don't display anything if not multiple pages
            if (pager.TotalPageCount == 1)
                return string.Empty;

            // Build route data
            var routeData = new RouteValueDictionary(helper.ViewContext.RouteData.Values);

            // Build string
            var sb = new StringBuilder();

            // Render Newer Entries
            if (pager.PageIndex > 0)
            {
                routeData["page"] = pager.PageIndex - 1;
                sb.Append(helper.ActionLink("Newer Entries", "Index", routeData));
            }

            // Render divider
            if (pager.PageIndex > 0 && pager.PageIndex < pager.TotalPageCount - 1)
                sb.Append(" | ");

            // Render Older Entries
            if (pager.PageIndex < pager.TotalPageCount - 1)
            {
                routeData["page"] = pager.PageIndex + 1;
                sb.Append(helper.ActionLink("Older Entries", "Index", routeData));
            }

            return sb.ToString();
        }
Example #8
0
        private IEnumerable<SaleProductModel> Convert(IPagedList<productDto> sources)
        {
            if (sources == null) return null;

            return sources.Select(t =>
                     {
                         var data = new SaleProductModel()
                         {
                             brandname = t.brand.name,
                             categoryname = t.category.name,
                             gendername = t.gender.name,
                             unitprice = t.unitprice,
                             code = t.code,
                             name = t.name,
                             imgpath = t.imagemain,
                             productid = t.key
                         };
                         data.details.AddRange(t.v_stocks.Select(o => new SaleProductDetailModel()
                         {
                             productid = t.key,
                             size = o.size.code,
                             displaysize = o.size.displaycode,
                             sizeid = o.sizeid,
                             stockquantity = o.stockquantity
                         }));
                         return data;
                     });
        }
Example #9
0
        /// <summary>
        /// Creates a new instance of the Pager class.
        /// </summary>
        /// <param name="pagination">The IPagination datasource</param>
        /// <param name="context">The view context</param>
        public Pager(IPagedList pagination, ViewContext context)
        {
            _pagination = pagination;
            _viewContext = context;

            _urlBuilder = CreateDefaultUrl;
        }
Example #10
0
        ///<summary>
        /// Displays a configurable "Go To Page:" form for instances of PagedList.
        ///</summary>
        ///<param name="html">This method is meant to hook off HtmlHelper as an extension method.</param>
        ///<param name="list">The PagedList to use as the data source.</param>
        ///<param name="formAction">The URL this form should submit the GET request to.</param>
        ///<param name="inputFieldName">The querystring key this form should submit the new page number as.</param>
        ///<returns>Outputs the "Go To Page:" form HTML.</returns>
        public static MvcHtmlString PagedListGoToPageForm(this System.Web.Mvc.HtmlHelper html,
		                                                  IPagedList list,
		                                                  string formAction,
		                                                  string inputFieldName)
        {
            return PagedListGoToPageForm(html, list, formAction, new GoToFormRenderOptions(inputFieldName));
        }
Example #11
0
        ///<summary>
        /// Displays a configurable "Go To Page:" form for instances of PagedList.
        ///</summary>
        ///<param name="html">This method is meant to hook off HtmlHelper as an extension method.</param>
        ///<param name="list">The PagedList to use as the data source.</param>
        ///<param name="formAction">The URL this form should submit the GET request to.</param>
        ///<param name="options">Formatting options.</param>
        ///<returns>Outputs the "Go To Page:" form HTML.</returns>
        public static MvcHtmlString PagedListGoToPageForm(this System.Web.Mvc.HtmlHelper html,
		                                         IPagedList list,
		                                         string formAction,
		                                         GoToFormRenderOptions options)
        {
            var form = new TagBuilder("form");
            form.AddCssClass("PagedList-goToPage");
            form.Attributes.Add("action", formAction);
            form.Attributes.Add("method", "get");

            var fieldset = new TagBuilder("fieldset");

            var label = new TagBuilder("label");
            label.Attributes.Add("for", options.InputFieldName);
            label.SetInnerText(options.LabelFormat);

            var input = new TagBuilder("input");
            input.Attributes.Add("type", options.InputFieldType);
            input.Attributes.Add("name", options.InputFieldName);
            input.Attributes.Add("value", list.PageNumber.ToString());

            var submit = new TagBuilder("input");
            submit.Attributes.Add("type", "submit");
            submit.Attributes.Add("value", options.SubmitButtonFormat);

            fieldset.InnerHtml = label.ToString();
            fieldset.InnerHtml += input.ToString(TagRenderMode.SelfClosing);
            fieldset.InnerHtml += submit.ToString(TagRenderMode.SelfClosing);
            form.InnerHtml = fieldset.ToString();
            return new MvcHtmlString(form.ToString());
        }
Example #12
0
 public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, string actionName, string controllerName, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         return AjaxPager(html, pagerOptions, null);
     }
     return html.AjaxPager(pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, actionName, controllerName, null, pagerOptions, ((RouteValueDictionary)null), ajaxOptions, ((IDictionary<string, object>)null));
 }
Example #13
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerExtensions/Method[@name="HtmlPager4"]/*'/>
 public static HtmlPager Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions)
 {
     if (pagedList == null)
     {
         throw new ArgumentNullException("pagedList");
     }
     return Pager(helper, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions);
 }
Example #14
0
 public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, string routeName, object routeValues, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         return AjaxPager(html, pagerOptions, null);
     }
     return html.AjaxPager(pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, routeName, pagerOptions, routeValues, ajaxOptions, null);
 }
Example #15
0
 public QuestionsModel(IPagedList<Question> questions, SiteState state)
 {
     SiteState = state;
     Questions = questions;
     state.Page = Convert.ToInt32(questions.CurrentPage);
     state.ItemCount = questions.TotalItems;
     state.MaxPages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(questions.TotalItems) / Convert.ToDouble(questions.PageSize)));
 }
Example #16
0
 public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes)
 {
     if (pagedList == null)
     {
         return AjaxPager(html, pagerOptions, htmlAttributes);
     }
     return html.AjaxPager(pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions, htmlAttributes);
 }
Example #17
0
 public SPlistViewModel(List<SPViewModel> picks, int? page)
 {
     if (page.HasValue)
     {
         _Page = page.Value;
     }
     _Picks = picks;
     _PickPages = _Picks.ToPagedList(_Page, 10);
 }
Example #18
0
 public static MvcHtmlString Pager(this HtmlHelper html, IPagedList list, string action, string controller)
 {
     var urlHelper = new UrlHelper(html.ViewContext.RequestContext);
     return html.PagedListPager(list,
                                page =>
                                urlHelper.Action(action, controller,
                                                 html.ViewContext.GetCombinedRouteValues(new {page = page})),
                                PagedListRenderOptions.DefaultPlusFirstAndLast);
 }
Example #19
0
 public static string GeneratePager(this HtmlHelper helper, IPagedList<object> data, string controller, string action, string pageParameter,params KeyValuePair<string, object>[] Parameters )
 {
     string url = "";
     foreach (var item in Parameters)
     {
         if(item.Value!= null)
         url += string.Format("&{0}={1}", item.Key, item.Value.ToString());
     }
     return helper.GeneratePager(data, controller, action, pageParameter, url, true);
 }
        public ActionResult Special(int? page, int? sortOption)
        {
            _products = offerLogic.GetSpecial();
            _onePageOfProducts = Common.SortAndPagin(sortOption, page, null, _products);

            if (Request.IsAjaxRequest())
            { return PartialView("_ProductListing", _onePageOfProducts); }

            return View(_onePageOfProducts);
        }
        public ActionResult Featured(int featuredPage)
        {
            _products = homeLogic.GetAllProducts();
            _specificProducts = _products.Where(x => x.IsFeatured);
            _onePageOfProducts = Common.SortAndPagin(1, featuredPage, 4, _specificProducts);
            if(Request.IsAjaxRequest())
            { return PartialView("_FeaturedProducts", _onePageOfProducts); }

            return View("Index");
        }
Example #22
0
            internal CmsPagerBuilder(IFrontHtmlHelper html, IPagedList pageList,
                PagerOptions pagerOptions, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)
                : base(html.Html, null, null, pageList, pagerOptions, null, routeValues, htmlAttributes)
            {
                frontHtml = html;
                this.routeValues = routeValues ?? new RouteValueDictionary();

                _pageList = pageList;
                this._pagerOptions = pagerOptions;
            }
        public DiscussionViewModel(Board board, IPagedList<PostViewModel> posts, int focusPostId, Competitor viewer)
        {
            Board = board;
            FocusPostId = focusPostId;
            Viewer = viewer != null && viewer.Status == CompetitorStatus.Active
                         ? new CompetitorViewModel(viewer)
                         : new CompetitorViewModel();

            Posts = posts;
        }
        public ActionResult Recent(int recentPage)
        {
            _products = _homeLogic.GetAllProducts();
            _specificProducts = _products.Where(x => x.IsRecent && x.Quantity > 0);
            _onePageOfProducts = Common.SortAndPagin(1, recentPage, 4, _specificProducts);

            if (Request.IsAjaxRequest())
            { return PartialView("_RecentProducts", _onePageOfProducts); }

            return View("Index");
        }
Example #25
0
 public RegistryItemsPage(IPagedList<Gift> gifts, IEnumerable<Category> categories, int pageSize,int selectedCategory)
 {
     Gifts =gifts.Select((gift, i) => new GiftRow {Item = gift, IsFirst = i == 0});
     Categories = categories.ToList();
     TotalNumberOfItems = gifts.TotalItemCount;
     PageNumber = gifts.PageNumber;
     PageCount = gifts.PageCount;
     FirstItemIndex = gifts.FirstItemIndex;
     LastItemIndex = gifts.LastItemIndex;
     PageSize = pageSize;
     SelectedCategoryId = selectedCategory;
 }
        public ActionResult Details(int id)
        {
            var product = _productLogic.GetProduct(id);
            if (product == null)
                return View("_Error");

            _products = _productLogic.GetSimilarProducts(6, product.Category.Name, product.ID);
            _onePageOfProducts = Common.SortAndPagin(null, 1, 6, _products);
            ViewData["similarProducts"] = _onePageOfProducts;

            return View(product);
        }
Example #27
0
        private static TagBuilder First(IPagedList list, Func<int, string> generatePageUrl, string format)
        {
            const int targetPageIndex = 0;
            var first = new TagBuilder("a");
            first.SetInnerText(string.Format(format, targetPageIndex + 1));

            if (list.IsFirstPage)
                return WrapInListItem(first, "PagedList-skipToFirst", "PagedList-disabled");

            first.Attributes["href"] = generatePageUrl(targetPageIndex);
            return WrapInListItem(first, "PagedList-skipToFirst");
        }
Example #28
0
 public SPViewModel(StaffPick pick, int? _page)
 {
     _Pick = pick;
     _Comms = Utilities.StaffPickDB.PickComments.Where(s => s.PickID == _Pick.ID).ToList();
     if (_page.HasValue)
     {
         Page = _page.Value;
     }
     _CommsPages = _Comms.ToPagedList( Page, 10);
     _Pics = Utilities.StaffPickDB.PickPictures.Where(s => s.PickID == _Pick.ID).ToList();
     _Songs = Utilities.StaffPickDB.PickSongs.Where(s => s.PickID == _Pick.ID).ToList();
     _Vids = Utilities.StaffPickDB.PickVideos.Where(s => s.PickID == _Pick.ID).ToList();
 }
Example #29
0
        public async Task GetHubsCallReturnsAnObjectResult(
            Mock<IRepository<HubDataModel>> hubRepository,
            IPagedList<HubDataModel> hubs,
            string hubSlug)
        {
            hubRepository.Setup(mock => mock.GetPaged(1, 100, null)).Returns(Task.FromResult(hubs));

            var controllerUnderTest = new HubController(hubRepository.Object);

            var result = await controllerUnderTest.GetPagedHubs(1, 100);

            Assert.IsAssignableFrom<IPagedList<HubDataModel>>(result);
        }
 ///<summary>
 /// Non-enumerable version of the PagedList class.
 ///</summary>
 ///<param name="pagedList">A PagedList (likely enumerable) to copy metadata from.</param>
 public PagedListMetaData(IPagedList pagedList)
 {
     PageCount = pagedList.PageCount;
     TotalItemCount = pagedList.TotalItemCount;
     PageNumber = pagedList.PageNumber;
     PageSize = pagedList.PageSize;
     HasPreviousPage = pagedList.HasPreviousPage;
     HasNextPage = pagedList.HasNextPage;
     IsFirstPage = pagedList.IsFirstPage;
     IsLastPage = pagedList.IsLastPage;
     FirstItemOnPage = pagedList.FirstItemOnPage;
     LastItemOnPage = pagedList.LastItemOnPage;
 }
        public ActionResult Index(int?categoryid, String searchstring, int?searchcriteria, int?itemPage, int?cateory, int?catPage, string sortoftion = "id", string sortoder = "asc")
        {
            HomePageViewModel viewmodel = new HomePageViewModel();

            viewmodel.SidenavbarCategory = db.Categories.Where(c => c.IsActive == true).ToList();



            if (searchstring != null && searchcriteria != null && categoryid == null)
            {
                viewmodel.Items = (from recode in db.ItemDetails where (recode.Name.Contains(searchstring) && recode.CategoryId == searchcriteria) select recode).OrderBy(c => c.Id).ToPagedList(itemPage ?? 1, 16);
            }
            else if (searchstring != null && searchcriteria == null && categoryid == null)
            {
                viewmodel.Items = (from recode in db.ItemDetails where recode.Name.Contains(searchstring) select recode).OrderBy(c => c.Id).ToPagedList(itemPage ?? 1, 16);
            }
            else
            {
                IPagedList iPagedList = null;


                if (categoryid.HasValue && categoryid != null)
                {
                    if (sortoftion == "name" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderBy(c => c.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "name" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderByDescending(c => c.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "category" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderBy(c => c.Category.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "name" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderByDescending(c => c.Category.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }


                    else if (sortoftion == "price" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderBy(c => c.UnitPrice).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "price" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderByDescending(c => c.UnitPrice).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else
                    {
                        viewmodel.Items = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true && i.CategoryId == categoryid).OrderBy(c => c.Id).ToPagedList(itemPage ?? 1, 16);
                    }
                }
                else
                {
                    if (sortoftion == "category" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderBy(c => c.Category.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "category" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderByDescending(c => c.Category.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }


                    else if (sortoftion == "name" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderBy(c => c.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "name" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderByDescending(c => c.Name).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }



                    else if (sortoftion == "price" && sortoder == "asc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderBy(c => c.UnitPrice).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else if (sortoftion == "price" && sortoder == "desc")
                    {
                        iPagedList      = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderByDescending(c => c.UnitPrice).ToPagedList(itemPage ?? 1, 16);
                        viewmodel.Items = iPagedList;
                    }
                    else
                    {
                        //iPagedList = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderByDescending(c => c.Name).ToPagedList(itemPage ?? 1, 16);
                        //viewmodel.Items = iPagedList;



                        viewmodel.Items = db.ItemDetails.Where(i => i.Category.IsActive == true && i.IsActive == true).OrderBy(c => c.Id).ToPagedList(itemPage ?? 1, 16);
                    }
                }
            }

            return(View(viewmodel));
        }
Example #32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="report"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public void ExportToXlsx(Stream stream, IPagedList<User> report, string path)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            // ok, we can run the real code of the sample now
            using (var xlPackage = new ExcelPackage(stream))
            {
                // uncomment this line if you want the XML written out to the outputDir
                //xlPackage.DebugMode = true; 

                // get handle to the existing worksheet
                var worksheet = xlPackage.Workbook.Worksheets.Add("User List");

                var header = new Dictionary<string, string>
                {
                    { "A1", "Account user ID"},
                    { "B1", "Full name"},
                    { "C1", "Role"},
                    { "D1", "Department"},
                    { "E1", "Active"},
                    { "F1", "Created date"}
                };

                foreach (var cell in header)
                {
                    HeaderStyle(worksheet.Cells[cell.Key], cell.Value);
                }


                #region create headers

                worksheet.Column(1).Width = 25;
                worksheet.Column(2).Width = 40;
                worksheet.Column(3).Width = 50;
                worksheet.Column(4).Width = 50;
                worksheet.Column(5).Width = 10;
                worksheet.Column(6).Width = 15;

                worksheet.Cells[1, 1, report.Count + 1, 32].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Black);

                #endregion

                #region create  content for excell           

                for (int i = 0; i < report.Count; i++)
                {
                    worksheet.Cells[i + 2, 1].Value = report[i].Username;
                    worksheet.Cells[i + 2, 2].Value = report[i].LastName + " " + report[i].FirstName;
                    worksheet.Cells[i + 2, 3].Value = String.Join(", ", report[i].UserRoles.Select(r=>r.Name));
                    worksheet.Cells[i + 2, 4].Value = String.Join(", ", report[i].Departments.Select(r => r.Name));
                    worksheet.Cells[i + 2, 5].Value = report[i].Active;
                    worksheet.Cells[i + 2, 6].Value = report[i].LastLoginDate.ToString("dd-MMM-yyyy");
                    
                }
                #endregion

                if (String.IsNullOrEmpty(path))
                {
                    xlPackage.Save(); // save to excell
                }
                else
                {
                    //Stream streamPath = File.Create(path);
                    //xlPackage.SaveAs(streamPath);

                    xlPackage.SaveAs(new FileInfo(path));

                    stream.Close();
                }
            }

        }
        /// <summary>
        /// Cast to Custom Type
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="selector">Selector</param>
        /// <typeparam name="TSource">Input Type</typeparam>
        /// <typeparam name="TResult">Result Type</typeparam>
        /// <returns>New PagedList</returns>
        public static IPagedList <TResult> Select <TSource, TResult>(this IPagedList <TSource> source, Func <TSource, TResult> selector)
        {
            var subset = ((IEnumerable <TSource>)source).Select(selector);

            return(new PagedList <TResult>(source, subset));
        }
Example #34
0
 public BenefitListModel(IPagedList <BenefitDto> list, BenefitListFiltersModel filters)
 {
     List    = list;
     Filters = filters;
 }
Example #35
0
 private void SetOrdersPage(int number)
 {
     this.currentPageOrders          = this.currentContext.GetOrdersPage(number);
     this.gridViewOrders.DataSource  = this.currentPageOrders.ToList();
     this.labelPageNumberOrders.Text = this.currentPageOrders.GuideText();
 }
 public DataSourceResult(IPagedList <T> pageList, string routeName) : base(pageList, routeName, null)
 {
 }
Example #37
0
 /// <summary>
 /// Try to get the paging info from the binding source.
 /// </summary>
 /// <param name="source">The paged list source.</param>
 /// <param name="currentPage">The output current page info.</param>
 /// <param name="totalPage">The output total page info.</param>
 private static void GetPagingInfoFromSource([NotNull] IPagedList source, out int currentPage, out int totalPage)
 {
     currentPage = source.PageIndex;
     totalPage   = source.TotalPage;
 }
Example #38
0
 public static PageViewModel Create(IPagedList <PostViewModel> pagedList)
 {
     return(new PageViewModel(pagedList));
 }
Example #39
0
        public IActionResult Index(int?pagina)
        {
            IPagedList <Models.Colaborador> colaboradores = _colaboradorRepository.ObterTodosColaboradores(pagina);

            return(View(colaboradores));
        }
        // Get films for the index view and builds a list of film viewmodels to return.
        // Utilises arguments to return a sorting order, page of results
        // and searched results. The sort order is tracked by the viewbag.
        public ActionResult Index(string errorMessage, string sortOrder, string searchString,
                                  string currentFilter, int?page)
        {
            // This section sets the search, ordering and pagination variables
            // from the values sent in the ActionResult arguments.
            ViewBag.CurrentSort = sortOrder;

            if (errorMessage != null)
            {
                ViewBag.ErrorMessage = errorMessage;
            }

            ViewBag.TitleSortParam = String.IsNullOrEmpty(sortOrder) ? "title_desc" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;



            List <FilmViewModel> filmList = new List <FilmViewModel>();



            // Get all films, then overwrite with returned results if a searchString
            // is specified.
            var films = from f in db.Films
                        select f;

            if (!String.IsNullOrEmpty(searchString))
            {
                films = films.Where(f => f.Title.Contains(searchString));
            }


            // Apply sorting based on the specified argument from the view.
            switch (sortOrder)
            {
            case "title_desc":
                films = films.OrderByDescending(f => f.Title);
                break;

            default:
                films = films.OrderBy(f => f.Title);
                break;
            }


            List <Film> theseFilms = new List <Film>();

            theseFilms = films.ToList();

            // Loop through film results and get viewmodel information from other db entities.
            // Assign the entities to the new viewmodel and add the viewmodel to the viewmodels list.
            foreach (Film thisFilm in theseFilms)
            {
                var averageReview = db.Reviews.Where(x => x.FilmId == thisFilm.FilmId)
                                    .Average(x => (int?)x.Rating) ?? 0;

                Certificate certificate = db.Certificates.Where(x => x.CertificateId == thisFilm.CertificateId).Single();

                FilmImage filmImage = db.FilmImages.Where(x => x.ImageId == thisFilm.ImageId).Single();

                FilmViewModel toAdd = new FilmViewModel();

                toAdd.ThisFilm        = thisFilm;
                toAdd.ThisFilmImage   = filmImage;
                toAdd.ThisCertificate = certificate;

                toAdd.averageReview = (int)averageReview;

                filmList.Add(toAdd);
            }


            // Set the amount of records shown on a page and convert the viewmodel
            // to an IpagedList object to return to the view.
            int pageSize = 5;
            // If page is null set to 1 otherwise keep page value.
            int pageNumber = (page ?? 1);

            IPagedList pagedList = filmList.ToPagedList(pageNumber, pageSize);

            return(View(pagedList));
        }
Example #41
0
        // GET: Medicine
        public ActionResult Index(FormCollection collection, int?page, string searchMedicine, string quantity, string resupply, string backButton)
        {
            try
            {
                int pageSize  = 5;
                int pageIndex = 1;
                pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;
                if (!String.IsNullOrEmpty(searchMedicine) && !String.IsNullOrEmpty(quantity))
                {
                    var element = new Medicine
                    {
                        name  = collection["searchMedicine"],
                        stock = int.Parse(collection["quantity"])
                    };

                    if (Storage.Instance.avlTree.searchValue(element, Medicine.CompareByName))
                    {
                        var found         = Storage.Instance.medicinesList.Find(s => s.name.Contains(element.name));
                        var elementToList = from s in Storage.Instance.medicinesList
                                            select s;
                        elementToList = elementToList.Where(s => s.name.Contains(found.name));
                        if ((element.stock <= found.stock) && ((found.stock - element.stock) >= 0))
                        {
                            elementToList = elementToList.Where(s => s.name.Contains(found.name));
                            var foundValue = Storage.Instance.medicinesList.Find(s => s.name.Contains(found.name));
                            int newValue   = Storage.Instance.medicinesList.Find(s => s.name.Contains(found.name)).stock;
                            Storage.Instance.medicinesList.Find(s => s.name.Contains(found.name)).stock = newValue - element.stock;
                            Total = Convert.ToDouble(quantity) * foundValue.price;
                            Medicine.quantityMedicines       = quantity;
                            Storage.Instance.newOrder.Total += Total;
                            Storage.Instance.medicinesReturn.Add(found);
                            Storage.Instance.medicinesOrder.Add(foundValue);
                            return(View(elementToList.ToPagedList(pageIndex, pageSize)));
                        }
                    }
                }

                if (!String.IsNullOrEmpty(resupply))
                {
                    Resupply();
                }

                if (!String.IsNullOrEmpty(backButton))
                {
                    return(View());
                }

                Storage.Instance.medicinesReturn.Clear();

                foreach (var item in Storage.Instance.medicinesList)
                {
                    if (item.stock <= 0)
                    {
                        Storage.Instance.avlTree.deleteElement(item, Medicine.CompareByName);
                    }
                    else if (item.stock != 0)
                    {
                        Storage.Instance.medicinesReturn.Add(item);
                    }
                }

                IPagedList <Medicine> listMedicines = null;
                List <Medicine>       auxiliarMed   = new List <Medicine>();
                auxiliarMed   = Storage.Instance.medicinesReturn;
                listMedicines = auxiliarMed.ToPagedList(pageIndex, pageSize);
                return(View(listMedicines));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Example #42
0
        public static async Task <IPagedList <T> > QueryAsPagedAsync <T>(this SqlConnection sqlConnection, ISqlQuery <T> sqlQuery, IPagedList <T> pagedList, object conditionParameters = null, string orderBy = null, bool isDistinct = false)
            where T : class, new()
        {
            Check.NotNull(sqlConnection, nameof(sqlConnection));
            Check.NotNull(sqlQuery, nameof(sqlQuery));
            Check.NotNull(pagedList, nameof(pagedList));



            if (!orderBy.ValidateSort())
            {   //Validate for SQL injection
                throw new ArgumentException("orderBy argument is invalid", nameof(orderBy));
            }

            pagedList.Items = null;
            var query = new StringBuilder(string.Empty);

            query.AppendLine($"WITH T0 AS (SELECT {(isDistinct ? "DISTINCT" : "")} COUNT(0) OVER() AS OverAllRowCount,");
            query.AppendLine(sqlQuery.QueryExpression);
            var whereExpression = sqlQuery.WhereExpression;

            if (!string.IsNullOrWhiteSpace(whereExpression))
            {
                query.AppendLine("WHERE");
                query.AppendLine(whereExpression);
            }
            query.AppendLine("ORDER BY " + (string.IsNullOrWhiteSpace(orderBy) ? "ID DESC" : orderBy));
            var skip = (pagedList.PageIndex - 1) * pagedList.PageSize;

            query.AppendLine($"OFFSET {skip} ROWS FETCH NEXT {pagedList.PageSize} ROWS ONLY");
            query.AppendLine(")");
            query.AppendLine("SELECT * FROM T0");

            var sqlCommand      = query.ToString();
            int overAllRowCount = 0;
            var result          = new List <T>();

            using (var reader = await sqlConnection.ExecuteReaderAsync(sqlCommand, conditionParameters))
            {
                var rowParser = reader.GetRowParser <T>(typeof(T));
                while (reader.Read())
                {
                    if (reader.Depth == 0)
                    {
                        overAllRowCount = reader.GetInt32(Check.Not(reader.GetOrdinal("OverAllRowCount"), "OverAllRowCountIndex", w => w < 0));
                    }
                    result.Add(rowParser(reader));
                }

                pagedList.Items      = result;
                pagedList.TotalCount = overAllRowCount;
                pagedList.PageCount  = (int)Math.Ceiling(overAllRowCount / (double)pagedList.PageSize);
            }
            return(pagedList);
        }
Example #43
0
        public IActionResult Index(int?pagina, string pesquisa)
        {
            IPagedList <Models.Cliente> clientes = _clienterepository.ObterTodosClientes(pagina, pesquisa);

            return(View(clientes));
        }
 public DataSourceResult(IPagedList <T> pageList, string routeName, object param) : base(pageList, routeName, param)
 {
 }
Example #45
0
        ///<summary>
        ///	Displays a configurable paging control for instances of PagedList.
        ///</summary>
        ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param>
        ///<param name = "list">The PagedList to use as the data source.</param>
        ///<param name = "generatePageUrl">A function that takes the page number  of the desired page and returns a URL-string that will load that page.</param>
        ///<param name = "options">Formatting options.</param>
        ///<returns>Outputs the paging control HTML.</returns>
        public static HtmlString Pager(this System.Web.Mvc.HtmlHelper htmlHelper, IPagedList list, Func <int, string> generatePageUrl, PagerOptions options)
        {
            if (options.Display == PagerBehavior.Never || (options.Display == PagerBehavior.IfNeeded && list.PageCount <= 1))
            {
                return(null);
            }

            var listItemLinks = new List <TagBuilder>();

            //calculate start and end of range of page numbers
            var firstPageToDisplay   = 1;
            var lastPageToDisplay    = list.PageCount;
            var pageNumbersToDisplay = lastPageToDisplay;

            if (options.MaximumPageNumbersToDisplay.HasValue && list.PageCount > options.MaximumPageNumbersToDisplay)
            {
                // cannot fit all pages into pager
                var maxPageNumbersToDisplay = options.MaximumPageNumbersToDisplay.Value;
                firstPageToDisplay = list.PageNumber - maxPageNumbersToDisplay / 2;
                if (firstPageToDisplay < 1)
                {
                    firstPageToDisplay = 1;
                }
                pageNumbersToDisplay = maxPageNumbersToDisplay;
                lastPageToDisplay    = firstPageToDisplay + pageNumbersToDisplay - 1;
                if (lastPageToDisplay > list.PageCount)
                {
                    firstPageToDisplay = list.PageCount - maxPageNumbersToDisplay + 1;
                }
            }

            //first
            if (options.DisplayLinkToFirstPage == PagerBehavior.Always || (options.DisplayLinkToFirstPage == PagerBehavior.IfNeeded && firstPageToDisplay > 1))
            {
                listItemLinks.Add(First(list, generatePageUrl, options));
            }

            //previous
            if (options.DisplayLinkToPreviousPage == PagerBehavior.Always || (options.DisplayLinkToPreviousPage == PagerBehavior.IfNeeded && !list.IsFirstPage))
            {
                listItemLinks.Add(Previous(list, generatePageUrl, options));
            }

            //text
            if (options.DisplayPageCountAndCurrentLocation)
            {
                listItemLinks.Add(PageCountAndLocationText(list, options));
            }

            //text
            if (options.DisplayItemSliceAndTotal)
            {
                listItemLinks.Add(ItemSliceAndTotalText(list, options));
            }

            //page
            if (options.DisplayLinkToIndividualPages)
            {
                //if there are previous page numbers not displayed, show an ellipsis
                if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && firstPageToDisplay > 1)
                {
                    listItemLinks.Add(Ellipses(options));
                }

                foreach (var i in Enumerable.Range(firstPageToDisplay, pageNumbersToDisplay))
                {
                    //show delimiter between page numbers
                    if (i > firstPageToDisplay && !string.IsNullOrWhiteSpace(options.DelimiterBetweenPageNumbers))
                    {
                        listItemLinks.Add(WrapInListItem(options.DelimiterBetweenPageNumbers));
                    }

                    //show page number link
                    listItemLinks.Add(Page(i, list, generatePageUrl, options));
                }

                //if there are subsequent page numbers not displayed, show an ellipsis
                if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && (firstPageToDisplay + pageNumbersToDisplay - 1) < list.PageCount)
                {
                    listItemLinks.Add(Ellipses(options));
                }
            }

            //next
            if (options.DisplayLinkToNextPage == PagerBehavior.Always || (options.DisplayLinkToNextPage == PagerBehavior.IfNeeded && !list.IsLastPage))
            {
                listItemLinks.Add(Next(list, generatePageUrl, options));
            }

            //last
            if (options.DisplayLinkToLastPage == PagerBehavior.Always || (options.DisplayLinkToLastPage == PagerBehavior.IfNeeded && lastPageToDisplay < list.PageCount))
            {
                listItemLinks.Add(Last(list, generatePageUrl, options));
            }

            if (listItemLinks.Any())
            {
                //append class to first item in list?
                if (!string.IsNullOrWhiteSpace(options.ClassToApplyToFirstListItemInPager))
                {
                    listItemLinks.First().AddCssClass(options.ClassToApplyToFirstListItemInPager);
                }

                //append class to last item in list?
                if (!string.IsNullOrWhiteSpace(options.ClassToApplyToLastListItemInPager))
                {
                    listItemLinks.Last().AddCssClass(options.ClassToApplyToLastListItemInPager);
                }

                //append classes to all list item links
                foreach (var li in listItemLinks)
                {
                    foreach (var c in options.LiElementClasses ?? Enumerable.Empty <string>())
                    {
                        li.AddCssClass(c);
                    }
                }
            }

            //collapse all of the list items into one big string
            var listItemLinksString = listItemLinks.Aggregate(new StringBuilder(), (sb, listItem) => sb.Append(TagBuilderToString(listItem)), sb => sb.ToString());

            var ul = new TagBuilder("ul");

            AppendHtml(ul, listItemLinksString);
            foreach (var c in options.UlElementClasses ?? Enumerable.Empty <string>())
            {
                ul.AddCssClass(c);
            }

            if (options.UlElementattributes != null)
            {
                foreach (var c in options.UlElementattributes)
                {
                    ul.MergeAttribute(c.Key, c.Value);
                }
            }

            var outerDiv = new TagBuilder("div");

            foreach (var c in options.ContainerDivClasses ?? Enumerable.Empty <string>())
            {
                outerDiv.AddCssClass(c);
            }
            AppendHtml(outerDiv, TagBuilderToString(ul));

            return(new HtmlString(TagBuilderToString(outerDiv)));
        }
Example #46
0
 /// <summary>
 /// 不带参数
 /// </summary>
 /// <param name="pageList"></param>
 /// <param name="routeName"></param>
 /// <returns></returns>
 public static DataSourceResult <T> ToDataResult <T>(this IPagedList <T> pageList, string routeName = null) where T : class
 {
     return(new DataSourceResult <T>(pageList, routeName));
 }
Example #47
0
        ///<summary>
        /// Displays a configurable paging control for instances of PagedList.
        ///</summary>
        ///<param name="html">This method is meant to hook off HtmlHelper as an extension method.</param>
        ///<param name="list">The PagedList to use as the data source.</param>
        ///<param name="generatePageUrl">A function that takes the index of the desired page and returns a URL-string that will load that page.</param>
        ///<param name="options">Formatting options.</param>
        ///<returns>Outputs the paging control HTML.</returns>
        public static MvcHtmlString PagedListPager(this System.Web.Mvc.HtmlHelper html,
                                                   IPagedList list,
                                                   Func <int, string> generatePageUrl,
                                                   PagedListRenderOptions options)
        {
            var listItemLinks = new StringBuilder();

            //text
            //if (options.DisplayPageCountAndCurrentLocation)
            //    listItemLinks.Append(PageCountAndLocationText(list, options.PageCountAndCurrentLocationFormat));

            //text
            if (options.DisplayItemSliceAndTotal)
            {
                listItemLinks.Append(ItemSliceAndTotalText(list, options.ItemSliceAndTotalFormat));
            }

            //first
            if (options.DisplayLinkToFirstPage)
            {
                listItemLinks.Append(First(list, generatePageUrl, options.LinkToFirstPageFormat));
            }

            //previous
            if (options.DisplayLinkToPreviousPage)
            {
                listItemLinks.Append(Previous(list, generatePageUrl, options.LinkToPreviousPageFormat));
            }

            //page
            if (options.DisplayLinkToIndividualPages)
            {
                foreach (var i in Enumerable.Range(0, list.PageCount))
                {
                    listItemLinks.Append(Page(i, list, generatePageUrl, options.LinkToIndividualPageFormat));
                }
            }

            //next
            if (options.DisplayLinkToNextPage)
            {
                listItemLinks.Append(Next(list, generatePageUrl, options.LinkToNextPageFormat));
            }

            //last
            if (options.DisplayLinkToLastPage)
            {
                listItemLinks.Append(Last(list, generatePageUrl, options.LinkToLastPageFormat));
            }

            var ul = new TagBuilder("ul")
            {
                InnerHtml = listItemLinks.ToString()
            };

            var outerDiv = new TagBuilder("div");

            outerDiv.AddCssClass("PagedList-pager");
            outerDiv.InnerHtml = ul.ToString();

            return(new MvcHtmlString(outerDiv.ToString()));
        }
Example #48
0
 /// <summary>
 /// 带参数和一个其他数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="A"></typeparam>
 /// <typeparam name="M1"></typeparam>
 /// <param name="pageList"></param>
 /// <param name="param"></param>
 /// <param name="m1"></param>
 /// <param name="routeName"></param>
 /// <returns></returns>
 public static DataSourceResult <T, A, M1> ToDataResult <T, A, M1>(this IPagedList <T> pageList, A param, M1 m1, string routeName = null) where T : class where A : class where M1 : class
 {
     return(new DataSourceResult <T, A, M1>(pageList, param, m1, routeName));
 }
Example #49
0
 private void SetResultPage(int number)
 {
     this.currentPageResult          = this.currentContext.GetResultPage(number);
     this.gridViewResults.DataSource = this.currentPageResult.ToList();
     this.labelPageNumberResult.Text = this.currentPageResult.GuideText();
 }
Example #50
0
 /// <summary>
 /// app json格式数据列表
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="pageList"></param>
 /// <returns></returns>
 public static JsonSourceResult <T> ToJsonResult <T>(this IPagedList <T> pageList) where T : class
 {
     return(new JsonSourceResult <T>(pageList));
 }
Example #51
0
 private void SetAgentsPage(int number)
 {
     this.currentPageAgents          = this.currentContext.GetAgentsPage(number);
     this.gridViewAgents.DataSource  = currentPageAgents.ToList();
     this.labelPageNumberAgents.Text = this.currentPageAgents.GuideText();
 }
Example #52
0
        /// <summary>
        /// 转成 jquery.datatable数据对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pageList"></param>
        /// <returns></returns>
        public static DatatableModel <T> ToAjax <T>(this IPagedList <T> pageList)
        {
            DatatableModel <T> model = new DatatableModel <T>(pageList);

            return(model);
        }
        public async Task <IActionResult> Edit(int id)
        {
            var topic = await _db.Topics.FindByIdAsync(id, false);

            if (topic == null)
            {
                return(RedirectToAction("List"));
            }

            var model = await MapperFactory.MapAsync <Topic, TopicModel>(topic);

            await PrepareTopicModelAsync(topic, model);

            model.WidgetZone = topic.WidgetZone.SplitSafe(",").ToArray();
            model.CookieType = (int?)topic.CookieType;

            AddLocales(model.Locales, async(locale, languageId) =>
            {
                locale.ShortTitle      = topic.GetLocalized(x => x.ShortTitle, languageId, false, false);
                locale.Title           = topic.GetLocalized(x => x.Title, languageId, false, false);
                locale.Intro           = topic.GetLocalized(x => x.Intro, languageId, false, false);
                locale.Body            = topic.GetLocalized(x => x.Body, languageId, false, false);
                locale.MetaKeywords    = topic.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = topic.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle       = topic.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName          = await topic.GetActiveSlugAsync(languageId, false, false);
            });

            // Get menu links.
            IPagedList <MenuEntity> menus = null;
            var pageIndex = 0;

            do
            {
                menus = await _db.Menus
                        .ApplyStandardFilter(true)
                        .ToPagedList(pageIndex++, 500)
                        .LoadAsync();

                foreach (var menu in menus)
                {
                    foreach (var item in menu.Items.Where(x => x.ProviderName != null && x.ProviderName == "entity"))
                    {
                        var link = await _linkResolver.ResolveAsync(item.Model);

                        if (link.Type == LinkType.Topic && link.Id == topic.Id)
                        {
                            var url = Url.Action("EditItem", "Menu", new { id = item.Id, area = "Admin" });

                            var label = string.Concat(
                                menu.Title.NullEmpty() ?? menu.SystemName.NullEmpty() ?? "".NaIfEmpty(),
                                " » ",
                                item.Title.NullEmpty() ?? link.Label.NullEmpty() ?? "".NaIfEmpty());

                            model.MenuLinks[url] = label;
                        }
                    }
                }
            }while (menus.HasNextPage);

            return(View(model));
        }
Example #54
0
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     return(pagedList == null?Pager(ajax, pagerOptions, null) : Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex,
                                                                      null, null, null, pagerOptions, null, ajaxOptions, null));
 }
Example #55
0
 public IViewComponentResult Invoke(IPagedList modeloPaginado)
 {
     return(View(modeloPaginado));
 }
Example #56
0
 public static bool IsNullOrEmpty <T>(IPagedList <T> pagedList)
 {
     return(pagedList == null || !pagedList.State.HasItems);
 }
Example #57
0
        public NoisePollutionModel(List <NOISE_LIGHT_ODOUR_DB> lApplications, int?page)
        {
            var tempList = new List <NoisePollutionDTO>();

            if (lApplications != null)
            {
                foreach (NOISE_LIGHT_ODOUR_DB application in lApplications)
                {
                    NoisePollutionDTO applicationDTO = new NoisePollutionDTO()
                    {
                        BestContactTime       = application.BEST_TIME_TO_CONTACT,
                        ReferenceNumber       = application.REFERENCE_NUMBER,
                        Diagnostics           = application.DIAGNOSTICS,
                        FoodPremiseName       = application.FOOD_PREMISE_NAME,
                        Impact                = application.IMPACT,
                        IsFoodPremise         = application.IS_FOOD_PREMISE,
                        IsNewIssue            = application.IS_NEW_ISSUE,
                        NoiseType             = application.NOISE_TYPE,
                        DayDetails            = application.DAYTIME_EVENING,
                        WeekDetails           = application.WEEKEND_WEEKDAY,
                        ResidentialCommercial = application.RESIDENTIAL_COMMERCIAL,
                        ReportType            = application.REPORT_TYPE,
                        Other = application.OTHER,
                        PreferredCommunication = application.PREFERRED_COMMUNICATION,
                        UserAddress            = application.C_USER_ADDRESS_ONLY__FULL_ADDRESS,
                        UserUPRN = application.C_USER_ADDRESS_ONLY__UPRN
                    };

                    string formDateTime = Convert.ToDateTime(application.FORM_DATE).ToShortDateString() + "\n" +
                                          Convert.ToDateTime(application.FORM_TIME).ToShortTimeString();
                    applicationDTO.FormDateTime = formDateTime;

                    //There are two ways address details are captured. This code finds the empty one and uses the other to ensure as many fields are populated as possible
                    if (application.C_MANUAL_ADDRESS_ONLY_LLPG__POST_CODE != null)
                    {
                        string problemAddress = application.C_MANUAL_ADDRESS_ONLY_LLPG__ADDRESS_LINE_1 + "\n" +
                                                application.C_MANUAL_ADDRESS_ONLY_LLPG__ADDRESS_LINE_2 + "\n" +
                                                application.C_MANUAL_ADDRESS_ONLY_LLPG__ADDRESS_LINE_3 + "\n" +
                                                application.C_MANUAL_ADDRESS_ONLY_LLPG__ADDRESS_LINE_4 + "\n" +
                                                application.C_MANUAL_ADDRESS_ONLY_LLPG__POST_CODE;
                        applicationDTO.ProblemAddress = problemAddress;
                    }
                    else if (application.C_POSTCODE_SEARCH_LLPG__POSTCODE != null)
                    {
                        string problemAddress = application.C_POSTCODE_SEARCH_LLPG__ADDRESS_NAME + "\n" +
                                                application.C_POSTCODE_SEARCH_LLPG__LINE1 + "\n" +
                                                application.C_POSTCODE_SEARCH_LLPG__LINE2 + "\n" +
                                                application.C_POSTCODE_SEARCH_LLPG__LINE3 + "\n" +
                                                application.C_POSTCODE_SEARCH_LLPG__POSTCODE;
                        applicationDTO.ProblemAddress = problemAddress;
                    }

                    //To make the GUI more user-friendly I am manipulating the data here to be shown as yes or no on the dashboard as they are stored as bits in the database.
                    if (Convert.ToInt32(application.SENT_TO_CIVICA) == 0)
                    {
                        string sentToCivica = "No";
                        applicationDTO.SentToCivica = sentToCivica;
                    }
                    else
                    {
                        string sentToCivica = "Yes";
                        applicationDTO.SentToCivica = sentToCivica;
                    }

                    tempList.Add(applicationDTO);
                }

                lNoisePollutionDtos = tempList.ToPagedList(page ?? 1, 25);
            }
        }
Example #58
0
 ///<summary>
 ///	Displays a configurable paging control for instances of PagedList.
 ///</summary>
 ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param>
 ///<param name = "list">The PagedList to use as the data source.</param>
 ///<param name = "generatePageUrl">A function that takes the page number of the desired page and returns a URL-string that will load that page.</param>
 ///<returns>Outputs the paging control HTML.</returns>
 public static HtmlString Pager(this System.Web.Mvc.HtmlHelper htmlHelper, IPagedList list, Func <int, string> generatePageUrl)
 {
     return(Pager(htmlHelper, list, generatePageUrl, new PagerOptions()));
 }
Example #59
0
 protected AsyncListModel(IPagedList <T> items, int id)
 {
     _items = items;
     _id    = id;
 }
Example #60
0
        // GET: Payments
        public async Task <IActionResult> Index(int?page, string sortOrder, string searchString, DateTime FromDate, DateTime ToDate)
        {
            int pageSize  = int.Parse(_appSettings.Value.PageSize);
            int pageIndex = page.HasValue ? (int)page : 1;

            ViewData["PaymentSortParm"]     = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("payment_desc") ? "payment_asc" : "payment_desc";
            ViewData["MovTypeSortParm"]     = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("movType_desc") ? "movType_asc" : "movType_desc";
            ViewData["QuanMovTypeSortParm"] = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("quantType_desc") ? "quantType_asc" : "quantType_desc";
            ViewData["AmountSortParm"]      = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("amount_desc") ? "amount_asc" : "amount_desc";
            ViewData["PayMediaSortParm"]    = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("payMedia_desc") ? "payMedia_asc" : "payMedia_desc";
            ViewData["NameSortParm"]        = String.IsNullOrEmpty(sortOrder) || sortOrder.Equals("name_desc") ? "name_asc" : "name_desc";

            var payments = from u
                           in _context.Payment.Include(p => p.MovmentType)
                           .Include(p => p.User)
                           .Include(p => p.PaymentMedia)
                           select u;

            if (FromDate != DateTime.MinValue)
            {
                payments = payments.Where(s => s.PaymentDate >= FromDate);
            }

            if (ToDate != DateTime.MinValue)
            {
                payments = payments.Where(s => s.PaymentDate <= ToDate);
            }


            if (!String.IsNullOrEmpty(searchString))
            {
                payments = payments.Where(s => s.User.FullName.ToLower().Contains(searchString.ToLower()) ||
                                          s.User.DocumentNumber.ToLower().Contains(searchString.ToLower()));
            }

            switch (sortOrder)
            {
            case "name_asc":
                payments = payments.OrderBy(s => s.User.FullName);
                break;

            case "name_desc":
                payments = payments.OrderByDescending(s => s.User.FullName);
                break;

            case "payment_asc":
                payments = payments.OrderBy(s => s.PaymentDate);
                break;

            case "payment_desc":
                payments = payments.OrderByDescending(s => s.PaymentDate);
                break;

            case "movType_asc":
                payments = payments.OrderBy(s => s.MovementTypeId);
                break;

            case "movType_desc":
                payments = payments.OrderByDescending(s => s.MovementTypeId);
                break;

            case "quantType_asc":
                payments = payments.OrderBy(s => s.QuantityMovmentType);
                break;

            case "quantType_desc":
                payments = payments.OrderByDescending(s => s.QuantityMovmentType);
                break;

            case "amount_asc":
                payments = payments.OrderBy(s => s.Amount);
                break;

            case "amount_desc":
                payments = payments.OrderByDescending(s => s.Amount);
                break;

            case "payMedia_asc":
                payments = payments.OrderBy(s => s.PaymentMedia);
                break;

            case "payMedia_desc":
                payments = payments.OrderByDescending(s => s.PaymentMedia);
                break;

            default:
                payments = payments.OrderBy(s => s.PaymentDate);
                break;
            }


            IPagedList <Payment> paymentPaged = payments.ToPagedList(pageIndex, pageSize);

            return(View(paymentPaged));
            //return View(await payments.AsNoTracking().ToListAsync());
        }