public ActionResult Admin() { var dashbordModel = new AdminDashboardModel(); using (var db = new DataBaseDataContext()) { try { var files = db.FILE_DETAILs; var fileList = new List <FileDetailModel>(); foreach (var f in files) { var nf = new FileDetailModel(); nf.FILE_ID = f.FILE_ID; nf.FILE_NAME = f.FILE_NAME; nf.CREATED_DATE = (DateTime)f.CREATED_DATE; nf.ASSIGN_STAFF_ID = f.ASSIGN_STAFF_ID; nf.ASSIGN_DATE = f.ASSIGN_DATE; nf.IS_ASSIGN = f.IS_ASSIGN; nf.COMPLETE_IN_DAYS = f.COMPLETE_IN_DAYS; nf.DEADLINE_DATE = f.DEADLINE_DATE; nf.IS_PENDING = f.IS_PENDING; nf.IS_COMPLETED = f.IS_COMPLETED; nf.CREATED_BY = f.CREATED_BY; fileList.Add(nf); } dashbordModel.AllFiles = fileList; } catch (Exception ex) { } } return(View(dashbordModel)); }
protected async Task LoadDashboardValues(bool silent = false) { var proxy = ProxyFactory.GetProxyInstace(); var response = await proxy.ExecuteAsync(API.Endpoints.AccountEndpoints.AdminDashboard); if (!IsActivePage) { return; } if (response.Successful) { // dashboard = await response.GetDataAsync <AdminDashboardModel>(); // BindDashboardValues(); } else { if (!silent) { ShowApiError(response); } } }
public ActionResult index() { var roll = Convert.ToInt32(Session["Role"]); if (Convert.ToInt32(Session["Role"]) == 1) { ViewBag.AllFiles = _buss.getAllFilesList(); ViewBag.AllOfficers = _buss.GetAllUSer().Where(m => m.RollId == "3"); ViewBag.AllOperator = _buss.GetAllUSer().Where(m => m.RollId == "2");; return(View("SuperAdmin")); } if (Convert.ToInt32(Session["Role"]) == 2) { var adminModel = new AdminDashboardModel(); ViewBag.AllFiles = _buss.getAllFilesList(); //return View("Admin"); return(RedirectToAction("ShowAllFiles", "File")); } if (Convert.ToInt32(Session["Role"]) == 3) { //return View("Officer"); return(RedirectToAction("getFIleStaff", "File")); } return(View()); }
public ActionResult GetDashboard() { using (ProjectEntities db = new ProjectEntities()) { var TotalPatient = db.Patients.Count(); var TotalDoctor = db.Doctors.Count(); var TotalSupplier = db.Suppliers.Count(); var TotalOrders = db.PatientOrderDetails.Count(); var Assigned = db.DrugDeliveries.Count(); var NotAssigned = TotalOrders - Assigned; var Requested = db.PatientOrderDetails.Where(a => a.OrderStatus == "Requested").Count(); var Dispatched = db.PatientOrderDetails.Where(a => a.OrderStatus == "Dispatched").Count(); var Delivered = db.PatientOrderDetails.Where(a => a.OrderStatus == "Delivered").Count(); AdminDashboardModel model = new AdminDashboardModel(); model.TotalPatient = TotalPatient; model.TotalDoctor = TotalDoctor; model.TotalSupplier = TotalSupplier; model.TotalOrders = TotalOrders; model.Assigned = Assigned; model.NotAssigned = NotAssigned; model.Requested = Requested; model.Dispatched = Dispatched; model.Delivered = Delivered; return(View("Dashboard", model)); } }
public async Task <IActionResult> Privacy() { AdminDashboardModel adminviewModel = new AdminDashboardModel(); adminviewModel.Tickets = await _context.Ticket.ToListAsync(); adminviewModel.Assets = await _context.AssetModel.ToListAsync(); return(View(adminviewModel)); }
public AdminDashboardModel GetModelForAdmin(LoggedInUserDetails user) { // Check whether user has access if (!user.IsSysAdmin) { throw new BaseException("Access denied."); } // Setup result var result = new AdminDashboardModel(); result.AdminOrgName = user.Organization.Name; // Setup active organisations result.ActiveOrganisations = GetActiveOrganisations(); // Setup active users result.ActiveUsers = GetActiveUsers(); // Setup published data schemas result.PublishedDataSchemas = GetPublishedDataSchemas(); // Setup last 7 registered organisations result.Last7RegisteredOrgs = GetLast7RegisteredOrgs(); // Setup last 7 published data schemas result.Last7RegisteredSchemas = GetLast7PublishedSchemas(); // Setup published provders result.PublishedProviders = GetPublishedProviders(); // Setup published consumers result.FinalizedConsumers = GetFinalizedConsumers(); // Return result return(result); }
public ActionResult AdminDashboard() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/Admin/AdminDashboard" })); } ViewBag.Title = "AdminDashboard"; ViewBag.Authorized = true; ViewBag.LoadAjaxJS = true; ViewBag.LoadValidationScript = true; AdminDashboardModel Dashboard = new AdminDashboardModel(); Dashboard.NoteInReview = AdminNoteRepository.GetCountNotesInReview(); Dashboard.Downloads = AdminDownloadRepository.CountNewDownloads(); Dashboard.NewUsers = AdminUserRepository.CountNewUsers(); Dashboard.PublishedNotes = AdminNoteRepository.GetPublishedNotes(); return(View(Dashboard)); }
public DALAdminDashboard() { _adminDashboard = new AdminDashboardModel(); }
public async Task <AdminDashboardModel> GetAdminDashboard() { AdminDashboardModel dashboard = new AdminDashboardModel() { Buses = new AdminDashboardModel.BusSpec(), Money = new AdminDashboardModel.MoneySpec <double>(), Reservations = new AdminDashboardModel.ReservationSpec <long>(), Routes = new AdminDashboardModel.RoutesSpec(), Users = new AdminDashboardModel.UsersSpec() }; // var reservations = DB.Reservations.Select(x => new { x.DateCreated, x.Cancelled, x.Route.DepartureTime, x.Route.ArrivalTime }).AsNoTracking().Future(); var users = DB.Users.Where(x => x.Claims.FirstOrDefault(t => t.ClaimType == ClaimTypes.Role).Value == UserRoles.User).Select(x => new { x.DateCreated, x.EmailConfirmed, x.PhoneConfirmed, x.LockedOut, }).AsNoTracking().Future(); var buses = DB.Buses.Select(x => new { x.DateCreated, Routes = x.Routes.Select(t => new { t.DateCreated, t.ArrivalTime, t.DepartureTime }) }).AsNoTracking().Future(); var transactions = DB.Transactions.Select(x => new { x.DateCreated, x.Status, x.Type, x.IdealAmount }).AsNoTracking().Future(); var routes = DB.Routes.Select(x => new { x.DateCreated, x.ArrivalTime, x.DepartureTime }).AsNoTracking().Future(); // var qReservations = await reservations.ToListAsync(); dashboard.Reservations.Total = qReservations.Count; foreach (var r in qReservations) { 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++; } 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 qUsers = await users.ToListAsync(); dashboard.Users.TotalUsers = qUsers.Count; foreach (var u in qUsers) { if ((u.EmailConfirmed || u.PhoneConfirmed) && !u.LockedOut) { if (DateHelper.IsToday(u.DateCreated)) { dashboard.Users.RegisteredToday++; } if (DateHelper.IsYesterday(u.DateCreated)) { dashboard.Users.RegisteredYesterday++; } if (DateHelper.IsThisWeek(u.DateCreated)) { dashboard.Users.RegisteredWeek++; } if (DateHelper.IsThisMonth(u.DateCreated)) { dashboard.Users.RegisteredMonth++; } } if (!u.EmailConfirmed) { dashboard.Users.PendingActivation++; } } var qBuses = await buses.ToListAsync(); var activeBuses = qBuses.Where(x => x.Routes.Any(t => RouteHelpers.Categorize(t.DepartureTime, t.ArrivalTime) == BusRouteState.Active)); dashboard.Buses.Total = qBuses.Count; dashboard.Buses.TotalActive = activeBuses.Count(); foreach (var bus in qBuses) { var bRoutes = bus.Routes; if (bRoutes.Any(x => DateHelper.IsToday(x.DepartureTime))) { dashboard.Buses.ActiveToday++; } if (bRoutes.Any(x => DateHelper.IsYesterday(x.DepartureTime))) { dashboard.Buses.ActiveYesterday++; } if (bRoutes.Any(x => DateHelper.IsThisWeek(x.DepartureTime))) { dashboard.Buses.ActiveWeek++; } if (bRoutes.Any(x => DateHelper.IsToday(x.ArrivalTime))) { dashboard.Buses.CompleteToday++; } if (bRoutes.Any(x => DateHelper.IsYesterday(x.ArrivalTime))) { dashboard.Buses.CompleteYesterday++; } if (bRoutes.Any(x => DateHelper.IsThisWeek(x.ArrivalTime))) { dashboard.Buses.CompleteWeek++; } } var qTransactions = await transactions.ToListAsync(); var refundedTxn = qTransactions.Where(x => x.Type == TransactionType.Refund && x.Status == TransactionStatus.Successful); dashboard.Money.Refunded = refundedTxn.Count() == 0 ? 0 : refundedTxn.Sum(x => x.IdealAmount); foreach (var t in qTransactions.Where(x => x.Status == TransactionStatus.Successful && x.Type == TransactionType.Charge)) { 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; } dashboard.Money.Total += t.IdealAmount; } // var qRoutes = await routes.ToListAsync(); dashboard.Routes.Total = qRoutes.Count; return(dashboard); }
//public ActionResult LoginAd() //{ // var banner = _adCampaignService.GetRandomAds("Login", "Click", "", 1); // var b = banner.FirstOrDefault(); // if (b == null || _workContext.CurrentCustomer.IsAdmin()) // { // return RedirectToAction("Index"); // } // return View(b); //} public ActionResult Index() { if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators")) { var allRoles = _customerService.GetAllCustomerRoles(true); var registeredRoleId = allRoles.First(x => x.SystemName.IsCaseInsensitiveEqual(SystemCustomerRoleNames.Registered)).Id; AdminDashboardModel model = new AdminDashboardModel(); model.RegisteredMembers = _customerService.GetAllCustomers(null, null, new int[] { registeredRoleId }, null, null, null, null, 0, 0, null, null, null, false, null, 0, int.MaxValue).TotalCount; model.ActiveMembers = _customerPlanService.GetAllCustomerPlans().Select(x => x.CustomerId).Distinct().Count(); int[] StatusIds = "2".ToIntArray(); int[] TranscationTypeIds = { (int)TransactionType.Withdrawal }; var transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIds, 0, int.MaxValue); model.CompletedWithdrawals = transcation.Sum(x => x.Amount); StatusIds = "1".ToIntArray(); transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIds, 0, int.MaxValue); model.PendingWithdrawals = transcation.Sum(x => x.Amount); StatusIds = "2".ToIntArray(); int[] TranscationTypeIdsC = { (int)TransactionType.Commission }; transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIdsC, 0, int.MaxValue); model.CommissionPaid = transcation.Sum(x => x.Amount); var plans = _planService.GetAllPlans(); double totalInvestors = 0, totalInvestment = 0, totalROIPaid = 0, totalROIToPay = 0, totalPendingROI = 0; foreach (var plan in plans) { var plandetails = _customerPlanService.GetAllCustomerPlans(0, plan.Id).ToList(); DashboardPlan dashboardPlan = new DashboardPlan(); dashboardPlan.Name = plan.Name; dashboardPlan.TotalInvestors = plandetails.Select(x => x.CustomerId).Distinct().Count().ToString(); dashboardPlan.TotalInvestment = plandetails.Sum(x => x.AmountInvested).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.ROIPaid = plandetails.Sum(x => x.ROIPaid).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.ROIToPay = plandetails.Sum(x => x.ROIToPay).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.PendingROI = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.TotalInvestorsInt = plandetails.Select(x => x.CustomerId).Distinct().Count(); dashboardPlan.TotalInvestmentInt = plandetails.Sum(x => x.AmountInvested); dashboardPlan.ROIPaidInt = plandetails.Sum(x => x.ROIPaid); dashboardPlan.ROIToPayInt = plandetails.Sum(x => x.ROIToPay); dashboardPlan.PendingROIInt = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)); totalInvestors = Convert.ToInt32(totalInvestors) + Convert.ToInt32(dashboardPlan.TotalInvestorsInt); totalInvestment = Convert.ToDouble(totalInvestment) + Convert.ToDouble(dashboardPlan.TotalInvestmentInt); totalROIPaid = Convert.ToDouble(totalROIPaid) + Convert.ToDouble(dashboardPlan.ROIPaidInt); totalROIToPay = Convert.ToDouble(totalROIToPay) + Convert.ToDouble(dashboardPlan.ROIToPayInt); totalPendingROI = Convert.ToDouble(totalPendingROI) + Convert.ToDouble(dashboardPlan.PendingROIInt); model.Plans.Add(dashboardPlan); } DashboardPlan plantotal = new DashboardPlan(); plantotal.Name = "Total"; plantotal.TotalInvestors = totalInvestors.ToString(); plantotal.TotalInvestment = totalInvestment.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.ROIPaid = totalROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.ROIToPay = totalROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.PendingROI = totalPendingROI.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; model.Plans.Add(plantotal); return(View("Dashboard", model)); } else { HomeModel model = new HomeModel(); model.ReferralLink = _services.StoreContext.CurrentStore.Url + "?r=" + _workContext.CurrentCustomer.Id; var id = _workContext.CurrentCustomer.Id; model.AvailableBalance = _customerService.GetAvailableBalance(id); //model.RepurchaseBalance = _customerService.GetRepurchaseBalance(id); model.CompletedWithdrawal = _customerService.GetCustomerCompletedWithdrawal(id); model.PendingWithdrawal = _customerService.GetCustomerPendingWithdrawal(id); model.TotalEarning = _customerService.GetCustomerTotalEarnings(id); model.TotalIncome = model.TotalEarning; model.CyclerIncome = _customerService.GetCustomerCyclerBonus(id); model.DirectBonus = _customerService.GetCustomerDirectBonus(id); model.UnilevelEarning = _customerService.GetCustomerUnilevelBonus(id); model.PoolShare = _customerService.GetCustomerROI(id) + _customerService.GetRepurchaseROI(id); model.TotalReferral = _customerService.GetCustomerReferral(id).Count(); model.InvestorId = "MTH" + id.ToString(); model.Name = _workContext.CurrentCustomer.GetFullName(); model.ReferredBy = _customerService.GetCustomerById(_workContext.CurrentCustomer.AffiliateId).GetFullName(); model.RegistrationDate = _workContext.CurrentCustomer.CreatedOnUtc.ToLongDateString(); model.Status = _workContext.CurrentCustomer.Transaction.Where(x => x.StatusId == 2 && x.TranscationTypeId == 1).Sum(x => x.Amount) > 0 ? "Active" : "Inactive"; model.VacationModelExpiryDate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate).ToShortDateString(); var lastsurfeddate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.LastSurfDate); if (lastsurfeddate.Date < DateTime.Today) { model.NoOfAdsToSurf = 10; } else { model.NoOfAdsToSurf = _workContext.CurrentCustomer.GetAttribute <int>(SystemCustomerAttributeNames.NoOfAdsSurfed); int ads = (10 - model.NoOfAdsToSurf); if (ads < 0) { model.NoOfAdsToSurf = 0; } else { model.NoOfAdsToSurf = (10 - model.NoOfAdsToSurf); } } var vacationdate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate); if (vacationdate > DateTime.Today) { model.NoOfAdsToSurf = 0; } ViewBag.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode; return(View(model)); } }
public ActionResult Index() { if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators")) { var allRoles = _customerService.GetAllCustomerRoles(true); var registeredRoleId = allRoles.First(x => x.SystemName.IsCaseInsensitiveEqual(SystemCustomerRoleNames.Registered)).Id; AdminDashboardModel model = new AdminDashboardModel(); model.RegisteredMembers = _customerService.GetAllCustomers(null, null, new int[] { registeredRoleId }, null, null, null, null, 0, 0, null, null, null, false, null, 0, int.MaxValue).TotalCount; model.ActiveMembers = _customerPlanService.GetAllCustomerPlans().Select(x => x.CustomerId).Distinct().Count(); model.ActiveMembers = model.ActiveMembers + _boardService.GetAllPosition(1, 0, false, 0, int.MaxValue).Select(x => x.CustomerId).Distinct().Count(); int[] StatusIds = "2".ToIntArray(); int[] TranscationTypeIds = { (int)TransactionType.Withdrawal }; var transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIds, 0, int.MaxValue); model.CompletedWithdrawals = transcation.Sum(x => x.Amount); StatusIds = "1".ToIntArray(); transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIds, 0, int.MaxValue); model.PendingWithdrawals = transcation.Sum(x => x.Amount); StatusIds = "2".ToIntArray(); int[] TranscationTypeIdsC = { (int)TransactionType.Commission }; transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIdsC, 0, int.MaxValue); model.CommissionPaid = transcation.Sum(x => x.Amount); StatusIds = "2".ToIntArray(); int[] TranscationTypeIdsD = { (int)TransactionType.Funding }; transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIdsD, 0, int.MaxValue); model.TotalDeposit = transcation.Sum(x => x.Amount); model.TodaysDeposit = transcation.Where(x => x.TransactionDate.Day == DateTime.Today.Day && x.TransactionDate.Month == DateTime.Today.Month && x.TransactionDate.Year == DateTime.Today.Year).Sum(x => x.Amount); StatusIds = "1,2".ToIntArray(); transcation = _transactionService.GetAllTransactions(0, 0, null, null, StatusIds, TranscationTypeIds, 0, int.MaxValue); model.TodaysWithdrawal = transcation.Where(x => x.TransactionDate.Day == DateTime.Today.Day && x.TransactionDate.Month == DateTime.Today.Month && x.TransactionDate.Year == DateTime.Today.Year).Sum(x => x.Amount); var plans = _planService.GetAllPlans(); double totalInvestors = 0, totalInvestment = 0, totalROIPaid = 0, totalROIToPay = 0, totalPendingROI = 0; foreach (var plan in plans) { var plandetails = _customerPlanService.GetAllCustomerPlans(0, plan.Id).ToList(); DashboardPlan dashboardPlan = new DashboardPlan(); dashboardPlan.Name = plan.Name; dashboardPlan.TotalInvestors = plandetails.Select(x => x.CustomerId).Distinct().Count().ToString(); dashboardPlan.TotalInvestment = plandetails.Sum(x => x.AmountInvested).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.ROIPaid = plandetails.Sum(x => x.ROIPaid).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.ROIToPay = plandetails.Sum(x => x.ROIToPay).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.PendingROI = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; dashboardPlan.TotalInvestorsInt = plandetails.Select(x => x.CustomerId).Distinct().Count(); dashboardPlan.TotalInvestmentInt = plandetails.Sum(x => x.AmountInvested); dashboardPlan.ROIPaidInt = plandetails.Sum(x => x.ROIPaid); dashboardPlan.ROIToPayInt = plandetails.Sum(x => x.ROIToPay); dashboardPlan.PendingROIInt = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)); totalInvestors = Convert.ToInt32(totalInvestors) + Convert.ToInt32(dashboardPlan.TotalInvestorsInt); totalInvestment = Convert.ToDouble(totalInvestment) + Convert.ToDouble(dashboardPlan.TotalInvestmentInt); totalROIPaid = Convert.ToDouble(totalROIPaid) + Convert.ToDouble(dashboardPlan.ROIPaidInt); totalROIToPay = Convert.ToDouble(totalROIToPay) + Convert.ToDouble(dashboardPlan.ROIToPayInt); totalPendingROI = Convert.ToDouble(totalPendingROI) + Convert.ToDouble(dashboardPlan.PendingROIInt); model.Plans.Add(dashboardPlan); } DashboardPlan plantotal = new DashboardPlan(); plantotal.Name = "Total"; plantotal.TotalInvestors = totalInvestors.ToString(); plantotal.TotalInvestment = totalInvestment.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.ROIPaid = totalROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.ROIToPay = totalROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; plantotal.PendingROI = totalPendingROI.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; model.Plans.Add(plantotal); return(View("Dashboard", model)); } else { HomeModel model = new HomeModel(); model.ReferralLink = _services.StoreContext.CurrentStore.Url + "?r=" + _workContext.CurrentCustomer.Id; var id = _workContext.CurrentCustomer.Id; model.AvailableBalance = _customerService.GetAvailableBalance(id); //model.RepurchaseBalance = _customerService.GetRepurchaseBalance(id); model.CompletedWithdrawal = _customerService.GetCustomerCompletedWithdrawal(id); model.PendingWithdrawal = _customerService.GetCustomerPendingWithdrawal(id); model.TotalEarning = _customerService.GetCustomerTotalEarnings(id); model.TotalIncome = model.TotalEarning; model.CyclerIncome = _customerService.GetCustomerCyclerBonus(id); model.DirectBonus = _customerService.GetCustomerDirectBonus(id); model.UnilevelEarning = _customerService.GetCustomerUnilevelBonus(id); model.PoolShare = _customerService.GetCustomerROI(id) + _customerService.GetRepurchaseROI(id); model.TotalReferral = _customerService.GetCustomerDirectReferral(id).Count(); model.InvestorId = id.ToString(); model.Name = _workContext.CurrentCustomer.GetFullName(); model.ReferredBy = _customerService.GetCustomerById(_workContext.CurrentCustomer.AffiliateId).GetFullName(); model.RegistrationDate = _workContext.CurrentCustomer.CreatedOnUtc.ToLongDateString(); model.Status = _workContext.CurrentCustomer.CustomerPosition.Count() > 0 ? "Active" : "Inactive"; model.VacationModelExpiryDate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate).ToShortDateString(); var custPositions = _boardService.GetAllPosition(0, _workContext.CurrentCustomer.Id, false, 0, int.MaxValue).ToList(); var cycledPositions = _boardService.GetAllPosition(0, _workContext.CurrentCustomer.Id, true, 0, int.MaxValue).ToList(); var lastsurfeddate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.LastSurfDate); ViewBag.Standard = custPositions.Where(x => x.BoardId == 1).Count(); ViewBag.StandardCycled = cycledPositions.Where(x => x.BoardId == 1 && x.IsCycled == true).Count(); ViewBag.Business = custPositions.Where(x => x.BoardId == 2).Count(); ViewBag.BusinessCycled = cycledPositions.Where(x => x.BoardId == 2 && x.IsCycled == true).Count(); ViewBag.Premium = custPositions.Where(x => x.BoardId == 3).Count(); ViewBag.PremiumCycled = cycledPositions.Where(x => x.BoardId == 3 && x.IsCycled == true).Count(); ViewBag.Ultimate = custPositions.Where(x => x.BoardId == 4).Count(); ViewBag.UltimateCycled = cycledPositions.Where(x => x.BoardId == 4 && x.IsCycled == true).Count(); ViewBag.Diamond = custPositions.Where(x => x.BoardId == 5).Count(); ViewBag.DiamondCycled = cycledPositions.Where(x => x.BoardId == 5 && x.IsCycled == true).Count(); ViewBag.CustomerId = _workContext.CurrentCustomer.Id; //if(lastsurfeddate.Date < DateTime.Today) //{ // model.NoOfAdsToSurf = 10; //} //else //{ // model.NoOfAdsToSurf = _workContext.CurrentCustomer.GetAttribute<int>(SystemCustomerAttributeNames.NoOfAdsSurfed); // int ads = (10 - model.NoOfAdsToSurf); // if (ads < 0) // { // model.NoOfAdsToSurf = 0; // } // else // { // model.NoOfAdsToSurf = (10 - model.NoOfAdsToSurf); // } //} //var vacationdate = _workContext.CurrentCustomer.GetAttribute<DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate); //if(vacationdate > DateTime.Today) //{ // model.NoOfAdsToSurf = 0; //} ViewBag.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode; var substrans = _workContext.CurrentCustomer.Transaction.Where(x => x.StatusId == 2 && x.TranscationNote == "subscription").FirstOrDefault(); if (substrans != null) { var noOfDays = substrans.NoOfPosition * 30; ViewBag.SubscriptionDate = substrans.CreatedOnUtc.AddDays(noOfDays).ToShortDateString(); } return(View(model)); } }
public AdminHomePage() { OnLoaded += (s, rootFrame) => { lbTotalMoney = rootFrame.FindViewById <TextView>(Resource.Id.lb_total_money); lbMoneyToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_today); lbMoneyYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_yesterday); lbMoneyWeek = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_week); 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); lbReservationsTotal = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_total); lbReservationsActive = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_active); lbReservationsPending = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_pending); lbReservationsUsed = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_used); // lbRoutesTotal = rootFrame.FindViewById <TextView>(Resource.Id.lb_routes_total); // lbBusesTotal = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_total); lbBusesActive = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active); lbBusesIdle = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle); lbBusesCompleteToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_today); lbBusesCompleteYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_yesterday); lbBusesCompleteWeek = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_week); // lbBusesActiveToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_today); lbBusesActiveYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_yesterday); lbBusesActiveWeek = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_week); lbBusesIdleToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_today); lbBusesIdleYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_yesterday); lbBusesIdleWeek = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_week); // lbUsersTotal = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_total); lbUsersRegisteredToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_today); lbUsersRegisteredWeek = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_week); lbUsersRegisteredMonth = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_month); lbUsersRegisteredYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_yesterday); lbUsersPendingActivation = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_pending_activation); // swipeRefreshLayout = rootFrame.FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root); swipeRefreshLayout.SetColorSchemeColors(AvatarDisplay.DefaultColors.Take(4).Select(t => t.ToArgb()).ToArray()); swipeRefreshLayout.Refresh += async delegate { if (isBusy) { return; } using (BusyState.Begin(() => updateTimer.Stop(), () => updateTimer.Start())) using (Busy()) { await LoadDashboardValues(); } }; updateTimer.Elapsed += delegate { if (isBusy) { return; } if (!IsActivePage) { updateTimer.Stop(); return; } Activity.RunOnUiThread(async delegate { using (Busy(false)) { await LoadDashboardValues(true); } }); }; // dashboard = new AdminDashboardModel() { Buses = new AdminDashboardModel.BusSpec(), Money = new AdminDashboardModel.MoneySpec <double>(), Reservations = new AdminDashboardModel.ReservationSpec <long>(), Routes = new AdminDashboardModel.RoutesSpec(), Users = new AdminDashboardModel.UsersSpec() }; BindDashboardValues(); }; }
public ActionResult Dashboard(string search, string sort, string month, int?page) { // viewbag for searching, sorting and pagination ViewBag.Search = search; ViewBag.Sort = sort; ViewBag.PageNumber = page; ViewBag.Month = month; // get memberid int memberid = context.UserRoles.Where(x => x.Name.ToLower() == "member").Select(x => x.ID).FirstOrDefault(); // get statusid int submittedforreviewid = context.ReferenceData.Where(x => x.Value.ToLower() == "submitted for review").Select(x => x.ID).FirstOrDefault(); int inreviewid = context.ReferenceData.Where(x => x.Value.ToLower() == "in review").Select(x => x.ID).FirstOrDefault(); // current date and time var now = DateTime.Now; // viewbag for monthlist ViewBag.MonthList = Enumerable.Range(1, 6).Select(x => new { Value = now.AddMonths(-x + 1).ToString("MM").ToString(), Text = now.AddMonths(-x + 1).ToString("MMMM").ToString() }).ToList(); var last7days = DateTime.Now.AddDays(-7); AdminDashboardModel admindash = new AdminDashboardModel(); // get notereview count admindash.NotesInReview = context.SellerNotes.Where(x => (x.Status == submittedforreviewid || x.Status == inreviewid) && x.IsActive == true).Count(); // get notes downloaded count of last 7 days admindash.NotesDownloaded = context.Downloads.Where(x => x.AttachmentDownloadedDate > last7days).Count(); // get count of newly registered of last 7 days admindash.NewRegistration = context.Users.Where(x => x.RoleID == memberid && x.CreatedDate > last7days).Count(); // create list object of AdminDashboardViewModel.PublishedNotesList var notelist = new List <AdminDashboardModel.PublishedNotesList>(); //IEnumerable<AdminDashboardModel.PublishedNotesList> notelist; // get all published notes var publishednotelist = context.SellerNotes.Where(x => x.Status == 9); // get current month var currentMonth = DateTime.Now.ToString("MM"); foreach (var item in publishednotelist) { // filter notes based on selected month // default we have to show current month published note if (String.IsNullOrEmpty(month)) { month = DateTime.Now.ToString("MM"); ViewBag.Month = month; } // if current month - selectd month >= 0 then don't need to subtract year by 1 if (Convert.ToInt32(currentMonth) - Convert.ToInt32(month) >= 0) { // get year var year = Convert.ToInt32(DateTime.Now.ToString("yyyy")); // compare note's published month with bool selectedmonth = item.PublishedDate.Value.ToString("MM").Equals(month); // compare note's year with selected year bool selectedyear = item.PublishedDate.Value.ToString("yyyy").Equals(year.ToString()); // if one of them is false then we don't nedd to add notes in list if (selectedmonth == false || selectedyear == false) { continue; } } // if current month - selectd month < 0 then need to subtract year by 1 else { // subtract year by 1 var year = Convert.ToInt32(DateTime.Now.ToString("yyyy")) - 1; // compare note's month with selected month bool selectedmonth = item.PublishedDate.Value.ToString("MM").Equals(month); // compare note's year with year bool selectedyear = item.PublishedDate.Value.ToString("yyyy").Equals(year.ToString()); // if one of them is false then we don't nedd to add notes in list if (selectedmonth == false || selectedyear == false) { continue; } } // create object of AdminDashboardViewModel.PublishedNotesList var note = new AdminDashboardModel.PublishedNotesList(); // get attachment of notes var attachement = context.SellerNotesAttachements.Where(x => x.NoteID == item.ID); // get download history of given note var downloads = context.Downloads.Where(x => x.NoteID == item.ID && x.IsSellerHasAllowedDownload == true).Count(); // get seller var publisher = context.Users.Where(x => x.ID == item.SellerID).First(); // declare file size var decimal filesize = 0; // iterate through each attachment foreach (var files in attachement) { string filepath = Server.MapPath(files.FilePath + files.FileName); FileInfo file = new FileInfo(filepath); // count file size and add into filesize var filesize += file.Length; } note.ID = item.ID; note.Title = item.Title; note.Category = item.NoteCategories.Name; note.Publisher = publisher.FirstName + " " + publisher.LastName; note.PublishedDate = (DateTime)item.PublishedDate; note.Price = item.SellingPrice; note.SellType = item.IsPaid == true ? "Paid" : "Free"; note.FileSize = filesize; note.Downloads = downloads; decimal sizemb = 0, sizekb = 0; // get file size in mb if (note.FileSize / 1024 > 1024) { sizemb = note.FileSize / (1024 * 1024); } // get file size in kb else { sizekb = Math.Ceiling(note.FileSize / 1024); } // file size in kb or mb if (sizemb != 0) { note.FileSizeKBMB = sizemb.ToString("0.00") + " MB"; } else { note.FileSizeKBMB = sizekb.ToString() + " KB"; } // add note in notelist notelist.Add(note); } // if search is not empty then search from result if (!String.IsNullOrEmpty(search)) { search = search.ToLower(); notelist = notelist.Where(x => x.Title.ToLower().Contains(search) || x.Category.ToLower().Contains(search) || x.FileSizeKBMB.ToLower().Contains(search) || x.Price.ToString().Contains(search) || x.SellType.ToLower().Contains(search) || x.Publisher.ToLower().Contains(search) || x.PublishedDate.ToString("dd-MM-yyyy hh:mm").Contains(search) || x.Downloads.ToString().ToString().Contains(search) ).ToList(); } // create IENumerable List of AdminDashboardModel IEnumerable <AdminDashboardModel.PublishedNotesList> notespublish = notelist.AsEnumerable(); // sort result notespublish = SortTableDashboard(sort, notespublish); admindash.PublishedNotesLists = notespublish.ToList().AsQueryable().ToPagedList(page ?? 1, 5); return(View(admindash)); }
public ActionResult Index(string month, string search, string sortOrder, int adpage = 1) { ViewBag.Dashboard = "active"; var user = db.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault(); AdminDashboardModel adminDashboard = new AdminDashboardModel(); //InReview Note adminDashboard.InReview = db.SellerNotes.Where(x => x.IsActive == true && (x.Status == 2 || x.Status == 3)).Count(); //Last 7 day Download Note adminDashboard.Downlaod = db.Downloads.Where(x => x.ModifiedDate < DateTime.Now).ToList() .Where(x => x.ModifiedDate > DateTime.Now.AddDays(-7.0)).Count(); //Last 7 day Registration adminDashboard.SignUp = db.Users.Where(x => x.ModifiedDate < DateTime.Now).ToList() .Where(x => x.ModifiedDate > DateTime.Now.AddDays(-7.0)).Count(); DateTime dt = DateTime.Now; List <int> list = new List <int>(); list.Add(dt.Month); for (int i = 1; i < 6; i++) { list.Add(dt.Month - i <= 0 ? (dt.Month - i) + 12 : dt.Month - i); } ViewBag.MonthList = new List <SelectListItem> { new SelectListItem { Text = list[0].ToString(), Value = "0" }, new SelectListItem { Text = list[1].ToString(), Value = "1" }, new SelectListItem { Text = list[2].ToString(), Value = "2" }, new SelectListItem { Text = list[3].ToString(), Value = "3" }, new SelectListItem { Text = list[4].ToString(), Value = "4" }, new SelectListItem { Text = list[5].ToString(), Value = "5" } }; var Notes = db.SellerNotes.Where(x => x.IsActive == true && x.Status == 4).ToList(); if (!String.IsNullOrEmpty(search)) { Notes = Notes.Where(x => x.Title.Contains(search) || x.NoteCategory.Name.Contains(search) || (x.User1.FirstName + " " + x.User1.LastName).Contains(search) || x.User1.LastName.Contains(search) || x.User1.FirstName.Contains(search)).ToList(); } if (String.IsNullOrEmpty(month) || Convert.ToInt32(month) == 0) { dt = DateTime.Now; var firstDayOfMonth = new DateTime(dt.Year, dt.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); Notes = Notes.Where(x => x.PublishedDate >= firstDayOfMonth && x.PublishedDate <= lastDayOfMonth).OrderByDescending(x => x.PublishedDate).ToList(); } else { DateTime PreviousMonth = DateTime.Now.AddMonths(-(Convert.ToInt32(month))); var firstDayOfPMonth = new DateTime(PreviousMonth.Year, PreviousMonth.Month, 1); var lastDayOfPMonth = new DateTime(PreviousMonth.Year, PreviousMonth.Month, DateTime.DaysInMonth(PreviousMonth.Year, PreviousMonth.Month)); Notes = Notes.Where(x => x.PublishedDate >= firstDayOfPMonth && x.PublishedDate <= lastDayOfPMonth).OrderByDescending(x => x.PublishedDate).ToList(); } ViewBag.TitleSortParm = sortOrder == "Title" ? "Title_desc" : "Title"; ViewBag.CategorySortParm = sortOrder == "Category" ? "Category_desc" : "Category"; ViewBag.SellTypeSortParm = sortOrder == "SellType" ? "SellType_desc" : "SellType"; ViewBag.PriceSortParm = sortOrder == "Price" ? "Price_desc" : "Price"; ViewBag.PublisherSortParm = sortOrder == "Publisher" ? "Publisher_desc" : "Publisher"; ViewBag.NoOfDownloadSortParm = sortOrder == "NoOfDownload" ? "NoOfDownload_desc" : "NoOfDownload"; ViewBag.DateSortParm = sortOrder == "Date" ? "Date_desc" : "Date"; switch (sortOrder) { case "Title_desc": Notes = Notes.OrderByDescending(s => s.Title).ToList(); break; case "Title": Notes = Notes.OrderBy(s => s.Title).ToList(); break; case "Category_desc": Notes = Notes.OrderByDescending(s => s.NoteCategory.Name).ToList(); break; case "Category": Notes = Notes.OrderBy(s => s.NoteCategory.Name).ToList(); break; case "SellType_desc": Notes = Notes.OrderByDescending(s => s.IsPaid).ToList(); break; case "SellType": Notes = Notes.OrderBy(s => s.IsPaid).ToList(); break; case "Price_desc": Notes = Notes.OrderByDescending(s => s.SellingPrice).ToList(); break; case "Price": Notes = Notes.OrderBy(s => s.SellingPrice).ToList(); break; case "Publisher_desc": Notes = Notes.OrderByDescending(s => s.User1.FirstName).ToList(); break; case "Publisher": Notes = Notes.OrderBy(s => s.User1.FirstName).ToList(); break; case "NoOfDownload_desc": Notes = Notes.OrderByDescending(x => x.Downloads.Where(s => s.IsSellerHasAllowedDownload == true).Count()).ToList(); break; case "NoOfDownload": Notes = Notes.OrderBy(x => x.Downloads.Where(s => s.IsSellerHasAllowedDownload == true).Count()).ToList(); break; case "Date_desc": Notes = Notes.OrderByDescending(s => s.PublishedDate).ToList(); break; case "Date": Notes = Notes.OrderBy(s => s.PublishedDate).ToList(); break; default: Notes = Notes.OrderByDescending(s => s.PublishedDate).ToList(); break; } var pager = new ADPager(Notes.Count(), adpage); ViewBag.currentPage = pager.CurrentPage; ViewBag.endPage = pager.EndPage; ViewBag.startpage = pager.StartPage; ViewBag.pageNumber = adpage; ViewBag.srno = adpage; ViewBag.TotalADPage = Math.Ceiling(Notes.Count() / 5.0); adminDashboard.SellerNotes = Notes.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(); return(View(adminDashboard)); }