예제 #1
0
        // GET: AgentManagerList
        public ActionResult AgentManagerList()
        {
            DashboardViewModel vm = new DashboardViewModel();
            var allUsersQquery = from user in db.AIAUsers
                                 orderby user.Id
                                 select user;

            List<AIAUser> allUsers = allUsersQquery.ToList();

            vm.AllAgentsList = allUsers;
            return View(vm);
        }
예제 #2
0
        // GET: Dashboard
        public ActionResult Main()
        {
            DashboardViewModel vm = new DashboardViewModel();

            DateTime now = DateTime.Now;

            int quotes = db.Quotes.Count(q => q.Price > 0);

            var recentQuoteQuery = from q in db.Quotes
                                   where q.SubmissionTime.Value.Month == now.Month
                                   orderby q.SubmissionTime.Value descending
                                   select q;

            List<Quote> recentQuotes = recentQuoteQuery.ToList();

            var recentAgentQuery = from agent in db.AIAUsers
                                   from q in recentQuoteQuery
                                   where agent.Id == q.AIAUserId
                                   orderby q.SubmissionTime.Value descending
                                   select agent;

            List<AIAUser> recentAgents = recentAgentQuery.ToList();

            var pendingAgents = from q in db.AIAUsers
                                where q.CanUseSystem == 0
                                orderby q.Id descending
                                select q;

            List<AIAUser> pendingAiaUsers = pendingAgents.ToList();

            //var userRoles = from q in db.AIAUsers
            //	join roles in db.AspNetUserRoles on roles. equals EXPR2
            //TODO: GET THE USER ROLES FROM EACH USER IN THE DATABASE!

            var topFiveQuery = (from q in recentQuoteQuery
                                orderby q.Price descending
                select q).Take(5);

            var topFiveAgentQuery = (from agent in db.AIAUsers
                from q in topFiveQuery
                where agent.Id == q.AIAUserId
                orderby q.Price descending
                select agent).Take(5);

            List<AIAUser> topFiveAgents = topFiveAgentQuery.ToList();

            List<Quote> topQuotes = topFiveQuery.ToList();

            List<decimal> userTotal = new List<decimal>();

            foreach (var quote in db.Quotes) {
                decimal total = new decimal();
                total += quote.Price;
                userTotal.Add(total);
            }

            decimal agentsRevenueTotal = new decimal();

            foreach (var item in recentQuotes) {
                agentsRevenueTotal += item.Price;
            }

            vm.TopFiveAgentList = topFiveAgents;
            vm.CompanyTotal = agentsRevenueTotal;
            vm.TopFiveQuoteList = topQuotes;
            vm.AgentTotalsList = userTotal;
            vm.RecentAiaUsersList = recentAgents;
            vm.PendingAiaUsersList = pendingAiaUsers;
            vm.RecentQuotesList = recentQuotes;
            vm.QuotesThisMonth = quotes;

            return View(vm);
        }