Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Index(string brand_name, int? page)
- {
- //returns IQueryable<Product> representing an unknown number of products. a thousand maybe?
- //var products = MyProductDataSource.FindAllProducts();
- ViewData["brand_name"] = brand_name;
- // if no page was specified in the querystring, default to the first page (1)
- var pageNumber = page.HasValue ? page.Value : 1;
- //ViewBag.OnePageOfProducts = onePageOfProducts;
- if (!string.IsNullOrWhiteSpace(brand_name))
- {
- // will only contain 12 products max because of the pageSize
- IPagedList<Material> onePageOfProducts = db.EContent_MaterialsFinalViewWithBcos
- .Select(i => new Material
- {
- Brand = i.Brand,
- Category = i.Category,
- Language = i.Language,
- Bco = i.Bco,
- MaterialCod = i.MaterialCod,
- Derivation = i.Derivation,
- Artwork = i.Artwork,
- BcoDelivery = i.BcoDelivery,
- MaterialId = i.MaterialId
- })
- .Where(p => p.Brand.ToLower() == brand_name.ToLower())
- .OrderBy(i => i.MaterialCod)
- .ToPagedList<Material>(pageNumber, defaultPageSize);
- return View("Index", onePageOfProducts);
- }
- else
- {
- // will only contain 12 products max because of the pageSize
- IPagedList<Material> onePageOfProducts = db.EContent_MaterialsFinalViewWithBcos
- .Select(i => new Material
- {
- Brand = i.Brand,
- Category = i.Category,
- Language = i.Language,
- Bco = i.Bco,
- MaterialCod = i.MaterialCod,
- Derivation = i.Derivation,
- Artwork = i.Artwork,
- BcoDelivery = i.BcoDelivery,
- MaterialId = i.MaterialId
- }).OrderBy(i => i.MaterialCod).ToPagedList<Material>(pageNumber, defaultPageSize);
- return View("Index", onePageOfProducts);
- }
- }
- @using PagedList.Mvc <!--import this so we get our HTML Helper-->
- @model IPagedList<eContentMVC.Models.Material>
- <div style="padding-top: 5px"></div>
- @using (Html.BeginForm("Index", "Materials", FormMethod.Get))
- {
- <div class="col-lg-3">
- <div class="input-group">
- <span class="input-group-btn">
- <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i> Search</button>
- </span>
- <input class="span2" id="appendedInputButton" type="text" name="brand_name" placeholder="Search Brand for..." />
- </div><!-- /input-group -->
- </div><!-- /.col-lg-3 -->
- <div style="padding-top: 20px"></div>
- <div id="grid-list">
- @{ Html.RenderPartial("_AjaxMaterialList", Model); }
- </div>
- }
- @using PagedList.Mvc <!--import this so we get our HTML Helper-->
- @model IPagedList<eContentMVC.Models.Material>
- <table>Some table here</table>
- <div class="panel panel-primary filterable">
- <div class="centerAlign">
- <!-- output a paging control that lets the user navigation to the previous page, next page, etc -->
- @Html.PagedListPager(Model, page => Url.Action("Index", "Materials", new
- {
- //It would be awesome if I could have some brand_name = brand
- page
- }))
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement