Permalink
Browse files

added optional page size parameter for invoice list

  • Loading branch information...
1 parent 0cb1890 commit 9ed8c80dc2ec247b96981c63174332c77eabf231 @iloire committed Jun 19, 2012
Showing with 7 additions and 7 deletions.
  1. +3 −3 iloire Facturacion Tests/InvoiceTest.cs
  2. +4 −4 iloire Facturacion/Controllers/InvoiceController.cs
@@ -23,7 +23,7 @@ public void TestSetup()
public void TestListInvoices()
{
InvoiceController ic = new InvoiceController();
- System.Web.Mvc.ViewResult result = ic.Index(null,null) as ViewResult;
+ System.Web.Mvc.ViewResult result = ic.Index(null,null,null) as ViewResult;
Assert.IsNotNull(result.ViewData.Model);
Assert.IsInstanceOf(typeof(IPagedList<Invoice>), result.ViewData.Model);
}
@@ -59,7 +59,7 @@ public void TestAddInvoice()
public void TestEditInvoice()
{
InvoiceController ic = new InvoiceController();
- ActionResult result = ic.Index(null,null);
+ ActionResult result = ic.Index(null,null,null);
ViewResult view = result as ViewResult;
Invoice i = ((IPagedList<Invoice>)view.ViewData.Model).First();
System.Web.Mvc.ActionResult invoiceEdition = ic.Edit(i.InvoiceID);
@@ -80,7 +80,7 @@ public void TestEditInvoice()
public void TestDeleteInvoice()
{
InvoiceController ic = new InvoiceController();
- System.Web.Mvc.ViewResult result = ic.Index(null,null) as ViewResult;
+ System.Web.Mvc.ViewResult result = ic.Index(null,null,null) as ViewResult;
Invoice i = ((IPagedList<Invoice>)result.ViewData.Model).First();
Assert.NotNull(i);
@@ -32,7 +32,7 @@ private void FillIndexViewBags(IPagedList<Invoice> invoices)
ViewBag.AdvancePaymentTaxAmountTotal = invoices.Sum(i => i.AdvancePaymentTaxAmount);
}
- public ViewResultBase Search(string text, string from, string to, int? page, bool? proposal = false)
+ public ViewResultBase Search(string text, string from, string to, int? page, int? pagesize, bool? proposal = false)
{
Session["invoiceText"] = text;
Session["invoiceFrom"] = from;
@@ -72,7 +72,7 @@ public ViewResultBase Search(string text, string from, string to, int? page, boo
else
invoices = invoices.Where(i => i.InvoiceNumber > 0); //we can not use Where(i => i.IsProposal) from within the LINQ db context
- invoices_paged = invoices.OrderByDescending(i => i.TimeStamp).ToPagedList(currentPageIndex, defaultPageSize);
+ invoices_paged = invoices.OrderByDescending(i => i.TimeStamp).ToPagedList(currentPageIndex, (pagesize.HasValue) ? pagesize.Value : defaultPageSize);
FillIndexViewBags(invoices_paged);
@@ -117,7 +117,7 @@ public PartialViewResult LastProposalsByCustomer(int id)
//
// GET: /Invoice/
- public ActionResult Index(string filter, int? page, bool? proposal = false)
+ public ActionResult Index(string filter, int? page, int? pagesize, bool? proposal = false)
{
#region remember filter stuff
if (filter == "clear")
@@ -150,7 +150,7 @@ public ActionResult Index(string filter, int? page, bool? proposal = false)
invoices = invoices.Where(i => i.InvoiceNumber > 0); //we can not use Where(i => i.IsProposal) from within the LINQ db context
}
- invoices_paged = invoices.OrderByDescending(i => i.TimeStamp).ToPagedList(currentPageIndex, defaultPageSize);
+ invoices_paged = invoices.OrderByDescending(i => i.TimeStamp).ToPagedList(currentPageIndex, (pagesize.HasValue) ? pagesize.Value : defaultPageSize);
FillIndexViewBags(invoices_paged);

0 comments on commit 9ed8c80

Please sign in to comment.