Exemplo n.º 1
0
        public AdminDashboardViewModel()
        {
            OpenCampaigns = (from a in db.Campaigns
                             where a.OpenCampaign.Equals(true)
                             select a).Count();

            ClosedCampaigns = (from b in db.Campaigns
                               where b.OpenCampaign.Equals(false)
                               select b).Count();

            Customers = (from c in db.Customers
                         select c).Count();

            UnqualifiedCustomers = (from d in db.Customers
                                    where d.Qualified.Equals(false)
                                    select d).Count();

            Vendors = (from e in db.Vendors
                       select e).Count();

            var _cust = (from f in db.Customers
                            where f.Qualified.Equals(true)
                            orderby f.Reviews.Count() descending
                            select f).Take(5).ToList();
            TopReviewers = new CustomerIndexViewModel(_cust);

            var _topvendors = (from g in db.Campaigns
                              orderby g.Reviews.Count() descending
                              select g.Vendor).Take(5).ToList();
            TopVendors = new VendorIndexViewModel(_topvendors);

            var _topcamps = (from h in db.Campaigns
                                  where h.OpenCampaign.Equals(true)
                                  orderby h.Reviews.Count() descending
                                  select h).Take(5).ToList();

            TopActiveCampaigns = new CampaignIndexViewModel(_topcamps);

            ActiveRequests = (from i in db.ItemRequests
                              where i.ActiveRequest.Equals(true)
                              select i).Count();
            CodesNeeded = (from j in db.Reviews
                           where j.Reviewed.Equals(false)
                           where j.DiscountCode.Equals(null)
                           select j).Count();

            TotalReviewsDone = (from j in db.Reviews
                           where j.Reviewed.Equals(true)
                           select j).Count();

            //Notifications count for today
            DateTime today = DateTime.Now.Date;
            NotificationsToday = (from n in db.NotificationLog
                                  where n.LogTimestamp > today
                                  select n).Count();


        }
Exemplo n.º 2
0
        // GET: Customer
        public ActionResult Index(bool showAll = false,string currentSearch = null)
        {
            //because there are so many customers, this index page takes too long to load.
            //By default I'm going to only show 50 customers. But a checkbox will allow to show all records
            //but will require longer load time.  

            CustomerIndexViewModel customers = new CustomerIndexViewModel(showAll, currentSearch);

            return View(customers);
        }