public ActionResult Search(string searchString, int amount, DateTime?date1, DateTime?date2, string department, string gl, int?page)
        {
            int count    = 0;
            int pageSize = 10;
            int pageNum  = (page ?? 1);

            int amount1 = 0;
            int amount2 = 0;


            var tempArray = new int[2];

            tempArray = amountList[amount];

            amount1 = tempArray.ElementAt(0);

            amount2 = tempArray.ElementAt(1);


            IEnumerable <DONATION> Donations = new List <DONATION>();

            if (searchString != null)
            {
                page      = 1;
                Donations = dnRepo.FindBy(searchString, amount1, amount2, date1, date2, department, gl);
            }

            count = Donations.Count();

            ChartDispalyViewModel model = new ChartDispalyViewModel();

            model.Donations = Donations.Take(count).ToPagedList(pageNum, pageSize);

            model.searchString = searchString;
            model.amount       = amount;
            model.date1        = date1;
            model.date2        = date2;
            model.department   = department;
            model.gl           = gl;

            LoadSelectList();


            return(View("~/Views/Chart/Index.cshtml", model));
        }
示例#2
0
        // GET: DONATIONs
        public ActionResult Index(string searchString, string sortOrder, string dateMade, string dateRecieved, int?page)
        {
            int count      = 0;
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            ViewBag.CurrentSort = sortOrder;

            if (searchString == null)
            {
                ViewBag.DonationSortParam = String.IsNullOrEmpty(sortOrder) ? "donationID_desc" : "";
                ViewBag.DateSortParam     = sortOrder == "DateGiftRecieved" ? "dateRecieved_desc" : "DateGiftRecieved";

                var donations = from DONATION d in dnRepo.GetDonations()
                                select d;

                count = donations.Count();
                //used to remove features for non-admin users.
                string userId = User.Identity.GetUserId();
                var    user   = data.AspNetUsers.FirstOrDefault(p => p.Id == userId);
                ViewBag.role = user.NewRole;

                DonationViewModel dvm = new DonationViewModel();
                //dvm.Donations = donations.Take(count).ToPagedList(pageNumber, pageSize);

                switch (sortOrder)
                {
                case "donationID_desc":
                    donations = donations.OrderByDescending(d => d.DONOR.FName);
                    break;

                case "DateGiftRecieved":
                    donations = donations.OrderBy(d => d.DateRecieved);
                    break;

                case "dateRecieved_desc":
                    donations = donations.OrderByDescending(d => d.DateRecieved);
                    break;

                default:
                    donations = donations.OrderBy(d => d.DONOR.FName);
                    break;
                }
                return(View(donations.Take(count).ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                IEnumerable <DONATION> donation = (IEnumerable <DONATION>)dnRepo.FindBy(searchString);
                count = donation.Count();

                return(View(donation.Take(count).ToPagedList(pageNumber, pageSize)));
            }
        }