Ejemplo n.º 1
0
        public IActionResult Index(string actionMessage = null)
        {
            var model = new UserDashboardModel(GetApplicationUser())
            {
                UserLoginListing = new LoginManager(Database).GetLogins().OrderByDescending(a => a.Timestamp).ToList(),
            };

            var jobs = new JobManager(Database).GetJobs();

            model.UsersListing = _userManager.GetUsers().Select(a => new UserListingItem
            {
                FirstName    = a.FirstName,
                LastName     = a.LastName,
                EmailAddress = a.EmailAddress,
                ID           = a.ID,
                LastLogin    = model.UserLoginListing.Where(b => b.UserID == a.ID).DefaultIfEmpty().Max(b => b?.Timestamp),
                NumJobs      = jobs.Count(b => b.SubmittedByUserID == a.ID)
            }).ToList();

            if (!string.IsNullOrEmpty(actionMessage))
            {
                model.ActionMessage = actionMessage;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public JsonResult getUserDashboard()
        {
            int  userid = Util.getLoginUserID();
            Util ut     = new Util();
            UserDashboardModel UserDashboard = ut.GetUserDetails(userid);

            return(Json(UserDashboard));
        }
        public ActionResult ManagePreference()
        {
            int userId = SessionManager.LoggedInUser.UserID;
            UserDashboardModel SmPreference = new UserDashboardModel();
            var preferences = _preferenceAPIController.GetPreference(userId);

            SmPreference.socialPreference = preferences;
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult UserDashboard()
        {
            int userid = Util.getLoginUserID();

            if (userid == 0)
            {
                return(new HttpNotFoundResult("User timed out. Please try to login again..."));
            }
            ViewBag.Title = String.Empty;
            Util ut = new Util();
            UserDashboardModel UserDashboard = ut.GetUserDetails(userid);

            return(View(UserDashboard));
        }
        public ActionResult UpdateLayout(UserDashboardModel model)
        {
            var userDashboard = _userDashboardRepository.GetAll()
                                .Where(d => d.UserId == this._workContext.CurrentUser.Id)
                                .FirstOrDefault();

            userDashboard.DashboardLayoutType = (int?)model.DashboardLayoutType;
            userDashboard.RegionCount         = model.RegionCount;
            userDashboard.UserDashboardVisuals.Clear();
            _userDashboardRepository.UpdateAndCommit(userDashboard);

            string html = "";

            html = this.RenderPartialViewToString("_Dashboard", model);
            return(Json(new { Html = html }));
        }
Ejemplo n.º 6
0
        protected virtual async Task LoadStatistics(bool silent = false)
        {
            var proxy    = ProxyFactory.GetProxyInstace();
            var response = await proxy.ExecuteAsync(API.Endpoints.AccountEndpoints.UserDashboard);

            if (response.Successful)
            {
                if (IsActivePage)
                {
                    //  Decode response
                    dashboardModel = await response.GetDataAsync <UserDashboardModel>();

                    //
                    BindDashboardValues();
                }
            }
            else
            {
                if (!silent)
                {
                    ShowApiError(response);
                }
            }
        }
Ejemplo n.º 7
0
        public async Task <UserDashboardModel> GetUserDashboard()
        {
            var user = DB.Users.Find(UserId);
            UserDashboardModel dashboard = new UserDashboardModel()
            {
                Money        = new UserDashboardModel.MoneySpec <double>(),
                Reservations = new UserDashboardModel.ReservationSpec <long>()
            };

            //
            var reservations = await DB.Reservations.AsNoDbSetFilter().Where(x => x.User.Id == UserId).Select(x => new
            {
                x.DateCreated,
                x.Route.DepartureTime,
                x.Route.ArrivalTime,
                x.Cancelled
            }).ToListAsync();

            dashboard.Reservations.Total = reservations.Count;
            foreach (var r in reservations)
            {
                if (DateHelper.IsToday(r.DateCreated))
                {
                    dashboard.Reservations.Today++;
                }

                if (DateHelper.IsYesterday(r.DateCreated))
                {
                    dashboard.Reservations.Yesterday++;
                }

                if (DateHelper.IsThisWeek(r.DateCreated))
                {
                    dashboard.Reservations.Week++;
                }

                if (DateHelper.IsThisMonth(r.DateCreated))
                {
                    dashboard.Reservations.Month++;
                }

                if (!r.Cancelled)
                {
                    switch (RouteHelpers.Categorize(r.DepartureTime, r.ArrivalTime))
                    {
                    case BusRouteState.Active:
                        dashboard.Reservations.Active++;
                        break;

                    case BusRouteState.Used:
                        dashboard.Reservations.Used++;
                        break;

                    case BusRouteState.Pending:
                        dashboard.Reservations.Pending++;
                        break;
                    }
                }
            }

            //
            var transactions = await DB.Transactions.Where(x => x.Wallet.User.Id == UserId).Select(x => new { x.DateCreated, x.IdealAmount, x.Type, x.Status }).AsNoTracking().ToListAsync();

            var successfulTxn = transactions.Where(x => x.Status == TransactionStatus.Successful &&
                                                   x.Type == TransactionType.Charge);

            dashboard.Money.Total = successfulTxn.Count() == 0 ? 0 : successfulTxn.Sum(x => x.IdealAmount);

            foreach (var t in successfulTxn)
            {
                if (DateHelper.IsToday(t.DateCreated))
                {
                    dashboard.Money.Today += t.IdealAmount;
                }

                if (DateHelper.IsYesterday(t.DateCreated))
                {
                    dashboard.Money.Yesterday += t.IdealAmount;
                }

                if (DateHelper.IsThisWeek(t.DateCreated))
                {
                    dashboard.Money.Week += t.IdealAmount;
                }

                if (DateHelper.IsThisMonth(t.DateCreated))
                {
                    dashboard.Money.Month += t.IdealAmount;
                }
            }

            var refundedTxn = transactions.Where(x => x.Type == TransactionType.Refund && x.Status == TransactionStatus.Successful);

            dashboard.Money.Refunded = refundedTxn.Count() == 0 ? 0 : refundedTxn.Sum(x => x.IdealAmount);

            return(dashboard);
        }
Ejemplo n.º 8
0
        public UserHomePage()
        {
            OnLoaded += (s, rootFrame) =>
            {
                //  Reservations section
                lbReservationsToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_today);
                lbReservationsYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_yesterday);
                lbReservationsWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_week);
                lbReservationsUsed      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_used);
                lbReservationsActive    = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_active);
                lbReservationsPending   = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_pending);
                lbReservationsTotal     = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_total);

                //  Money section
                lbMoneyTotal     = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_total_value);
                lbMoneyToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_today);
                lbMoneyYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_yesterday);
                lbMoneyRefunded  = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_refunded);

                //
                swipeRefreshLayout = rootFrame.FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root);
                swipeRefreshLayout.SetColorSchemeColors(Views.AvatarDisplay.DefaultColors.Take(4).Select(x => x.ToArgb()).ToArray());

                swipeRefreshLayout.Refresh += async delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    using (BusyState.Begin(() => updateTimer.Stop(), () => updateTimer.Start()))
                        using (Busy())
                        {
                            await LoadStatistics();
                        }
                };

                rootFrame.FindViewById <Button>(Resource.Id.btn_book_reservation).Click += delegate
                {
                    StartActivityForResult(new Intent(Activity, typeof(CreateReservationActivity)), CreateReservationLayout);
                };


                updateTimer.Elapsed += delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    if (!IsActivePage)
                    {
                        updateTimer.Stop();
                        return;
                    }

                    Activity.RunOnUiThread(async delegate
                    {
                        using (Busy(false))
                            await LoadStatistics(true);
                    });
                };

                dashboardModel = new UserDashboardModel()
                {
                    Money        = new UserDashboardModel.MoneySpec <double>(),
                    Reservations = new UserDashboardModel.ReservationSpec <long>()
                };

                BindDashboardValues();
            };
        }