Ejemplo n.º 1
0
        private static (List <CollectedOperationDataViewModel>, TotalsViewModel, List <OpportunitiesByUserViewModel>) collectSortedData(List <List <Operation> > list, DateTime[] startDate, DateTime[] endDate, List <User> users)
        {
            TotalsViewModel totals = new TotalsViewModel(0, 0, 0, 0, 0, 0, 0, new SourcesViewModel(0, 0, 0, 0, 0));
            List <CollectedOperationDataViewModel> collectedOperationsByDateRange = new List <CollectedOperationDataViewModel>();
            CollectedOperationDataViewModel        data;
            List <OpportunitiesByUserViewModel>    usersStats = new List <OpportunitiesByUserViewModel>();

            users.Remove(users.Find(x => x.UserName == "Admin"));

            foreach (var u in users)
            {
                var user = new OpportunitiesByUserViewModel(u.DisplayName, 0, 0);
                usersStats.Add(user);
            }

            for (int i = 0; i < list.Count; i++)
            {
                data = new CollectedOperationDataViewModel
                       (
                    startDate[i],
                    endDate[i],
                    list[i].Count(x => x.Lead == true),
                    list[i].Count(x => x.Opportunity == true),
                    list[i].Count(x => x.Quote == true),
                    list[i].Count(x => x.Invoice == true),
                    list[i].Count(x => x.Conversion == true),
                    list[i].Count(x => x.Order == true),
                    countRevenue(list[i]),
                    countSources(list[i])
                       );
                collectedOperationsByDateRange.Add(data);

                totals.LeadsTotal         += list[i].Count(x => x.Lead == true);
                totals.OpportunitiesTotal += list[i].Count(x => x.Opportunity == true);
                totals.QuotesTotal        += list[i].Count(x => x.Quote == true);
                totals.InvoicesTotal      += list[i].Count(x => x.Invoice == true);
                totals.ConversionsTotal   += list[i].Count(x => x.Conversion == true);
                totals.OrdersTotal        += list[i].Count(x => x.Order == true);
                list[i].ForEach(x => totals.RevenueTotal += x.Revenue);
                totals.SourcesTotal.Web          += list[i].Count(x => x.Source == "Web");
                totals.SourcesTotal.Flyers       += list[i].Count(x => x.Source == "Flyers");
                totals.SourcesTotal.Commercial   += list[i].Count(x => x.Source == "Commercial");
                totals.SourcesTotal.SocialMedia  += list[i].Count(x => x.Source.Equals("Social Media"));
                totals.SourcesTotal.FormerClient += list[i].Count(x => x.Source.Equals("Former Client"));

                foreach (var u in usersStats)
                {
                    u.LeadsTotal         += list[i].Count(x => x.Lead == true && x.UserOperation.User.DisplayName.Equals(u.UserDisplayName) == true);
                    u.OpportunitiesTotal += list[i].Count(x => x.Opportunity == true && x.UserOperation.User.DisplayName.Equals(u.UserDisplayName) == true);
                }
            }

            return(collectedOperationsByDateRange, totals, usersStats);
        }
Ejemplo n.º 2
0
        public ActionResult Totals()
        {
            var vm = new TotalsViewModel
            {
                SquawksTotals = _db.ExecuteScalar <int>(@"select count(*) from Squawks"),
                UserTotals    = _db.ExecuteScalar <int>(@"select count(*) from Users")
            };


            return(PartialView(vm));
        }
 public CompleteStatsViewModel(List <CollectedOperationDataViewModel> thisMonthData, TotalsViewModel thisMonthTotals,
                               List <CollectedOperationDataViewModel> oneMonthData, TotalsViewModel oneMonthTotals,
                               List <CollectedOperationDataViewModel> sixMonthsData, TotalsViewModel sixMonthsTotals,
                               List <OpportunitiesByUserViewModel> oneMonthOpportunitiesByUser, List <OpportunitiesByUserViewModel> sixMonthsOpportunitiesByUser)
 {
     ThisMonthTotals              = thisMonthTotals;
     ThisMonthData                = thisMonthData;
     OneMonthTotals               = oneMonthTotals;
     OneMonthData                 = oneMonthData;
     SixMonthsTotals              = sixMonthsTotals;
     SixMonthsData                = sixMonthsData;
     OneMonthOpportunitiesByUser  = oneMonthOpportunitiesByUser;
     SixMonthsOpportunitiesByUser = sixMonthsOpportunitiesByUser;
 }
        public HttpResponseMessage GetTotals()
        {
            try
            {
                var portalId        = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID);
                var totalsViewModel = new TotalsViewModel
                {
                    TotalUnreadMessages = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId),
                    TotalNotifications  = NotificationsController.Instance.CountNotifications(UserInfo.UserID, portalId)
                };

                return(Request.CreateResponse(HttpStatusCode.OK, totalsViewModel));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Ejemplo n.º 5
0
        public ActionResult GetTotals()
        {
            try
            {
                var portalId        = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID);
                var totalsViewModel = new TotalsViewModel
                {
                    TotalUnreadMessages = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId),
                    TotalNotifications  = NotificationsController.Instance.CountNotifications(UserInfo.UserID, portalId)
                };

                return(Json(totalsViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 6
0
        public HttpResponseMessage GetTotals()
        {
            try
            {
                var portalId        = PortalController.GetEffectivePortalId(UserController.Instance.GetCurrentUserInfo().PortalID);
                var totalsViewModel = new TotalsViewModel
                {
                    TotalUnreadMessages = InternalMessagingController.Instance.CountUnreadMessages(this.UserInfo.UserID, portalId),
                    TotalNotifications  = NotificationsController.Instance.CountNotifications(this.UserInfo.UserID, portalId),
                };

                return(this.Request.CreateResponse(HttpStatusCode.OK, totalsViewModel));
            }
            catch (Exception ex)
            {
                var message = "An unexpected error occurred while attempting to get the unread messages and new notifications count, consult the server logs for more information.";
                Logger.Error(message, ex);
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, message));
            }
        }