public ActionResult TransactionList(IFormCollection forms, int?page) { string personid = forms["personid"]; string firstday = forms["firstday"]; string lastday = forms["lastday"]; GetAccounts g = new GetAccounts(); List <TransactionsWithAccounts> returnList = g.TA(firstday, lastday, personid); ViewBag.CurrentSort = "TransactionDate"; ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.firstday = firstday; ViewBag.lastday = lastday; ViewBag.personid = personid; /* int pageSize = 20; * int pageNumber = (page ?? 1); */ return(View(returnList)); }
public ActionResult TransactionList(int?page, string personid, string firstday, string lastday, string sortOrder, bool?ChangeSort) { // DateTime fromDate = Convert.ToDateTime(firstday); // DateTime toDate = Convert.ToDateTime(lastday); GetAccounts g = new GetAccounts(); List <TransactionsWithAccounts> returnList = g.TA(firstday, lastday, personid); switch (sortOrder) { case "TransactionDate_desc": if (ChangeSort ?? false) { returnList.Sort((x, y) => DateTime.Compare(x.TransactionDate, y.TransactionDate)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "TransactionDate"; } else { returnList.Sort((x, y) => - 1 * DateTime.Compare(x.TransactionDate, y.TransactionDate)); ViewBag.DateSortParm = "TransactionDate_desc"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "TransactionDate_desc"; } break; case "TransactionDate": if (ChangeSort ?? false) { returnList.Sort((x, y) => - 1 * DateTime.Compare(x.TransactionDate, y.TransactionDate)); ViewBag.DateSortParm = "TransactionDate_desc"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "TransactionDate_desc"; } else { returnList.Sort((x, y) => DateTime.Compare(x.TransactionDate, y.TransactionDate)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "TransactionDate"; } break; case "AcctNumber": if (ChangeSort ?? false) { returnList.Sort((x, y) => - 1 * x.AccountNumber1.CompareTo(y.AccountNumber1)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber_desc"; ViewBag.CurrentSort = "AcctNumber_desc"; } else { returnList.Sort((x, y) => x.AccountNumber1.CompareTo(y.AccountNumber1)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "AcctNumber"; } break; case "AcctNumber_desc": if (ChangeSort ?? false) { returnList.Sort((x, y) => x.AccountNumber1.CompareTo(y.AccountNumber1)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber"; ViewBag.CurrentSort = "AcctNumber"; } else { returnList.Sort((x, y) => - 1 * x.AccountNumber1.CompareTo(y.AccountNumber1)); ViewBag.DateSortParm = "TransactionDate"; ViewBag.AcctSortParm = "AcctNumber_desc"; ViewBag.CurrentSort = "AcctNumber_desc"; } break; default: break; } /* int pageSize = 20; * int pageNumber = (page ?? 1); */ ViewBag.firstday = firstday; ViewBag.lastday = lastday; ViewBag.personid = personid; return(View(returnList)); }