public ActionResult AdminDashboard()
        {
            var viewModel      = new AdminReportViewModel();
            var bookingService = this.Service <IBookingReceiptService>();
            var vehicleService = this.Service <IVehicleService>();
            var userService    = this.Service <IUserService>();
            var garageService  = this.Service <IGarageService>();

            var utcNow      = DateTime.UtcNow;
            var activeUsers = userService.Get(u => !u.LockoutEnabled || u.LockoutEndDateUtc < utcNow);

            viewModel.NumOfActiveUser = activeUsers.Count(u => u.AspNetRoles.Any(r => r.Name != "Admin"));

            var activeProviders = activeUsers.Where(u => u.AspNetRoles.Any(r => r.Name == "Provider"));

            viewModel.NumOfActiveProvider = activeProviders.Count();

            viewModel.NumOfActiveGarage = garageService.Get(g => g.IsActive && activeProviders.Contains(g.AspNetUser)).Count();

            viewModel.NumOfActiveVehicle =
                vehicleService.Get()
                .Count(v => v.VehicleGroupID != null &&
                       v.VehicleGroup.IsActive &&
                       activeProviders.Contains(v.Garage.AspNetUser));

            // Current month's report
            var now       = DateTime.Now;
            var thisMonth = new DateTime(now.Year, now.Month, 1);

            var receipts = bookingService.Get(r => !r.IsPending && r.CustomerID != r.Garage.OwnerID &&
                                              r.BookingTime < now &&
                                              r.BookingTime.Month == thisMonth.Month &&
                                              r.BookingTime.Year == thisMonth.Year);

            viewModel.ThisMonthNumOfSuccessfulBooking = receipts.Count();
            if (receipts.Any())
            {
                viewModel.ThisMonthNumOfProfit = receipts.Sum(r => r.BookingFee);
            }

            // Calculate monthly reports for last half year
            for (var i = 1; i < 7; i++)
            {
                var reportTime = thisMonth.AddMonths(-i);
                receipts = bookingService.Get(r => !r.IsPending && r.CustomerID != r.Garage.OwnerID &&
                                              r.BookingTime < now &&
                                              r.BookingTime.Month == reportTime.Month &&
                                              r.BookingTime.Year == reportTime.Year);

                viewModel.AddMonthlyReport(receipts.ToList(), reportTime);
            }

            return(View("~/Areas/Admin/Views/Dashboard/Index.cshtml", viewModel));
        }
Example #2
0
        public ActionResult Report()
        {
            var adminReportViewModel = new AdminReportViewModel();

            adminReportViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
            adminReportViewModel.ListofAgent    = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "",
                    Text  = "-----Select-----"
                }
            };

            adminReportViewModel.ListofReport       = ReportList();
            adminReportViewModel.ListofOverdueTypes = _overdueTypes.GetAllActiveOverdueTypes();
            adminReportViewModel.ListofPriority     = _priority.GetAllPrioritySelectListItem();
            return(View(adminReportViewModel));
        }
Example #3
0
        public ActionResult Report(AdminReportViewModel reportViewModel)
        {
            if (ModelState.IsValid)
            {
                if (reportViewModel.ReportId == 1)
                {
                    var reportDetailTicketStatusReport = _exportReport.GetDetailTicketStatusReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.AgentId);

                    if (reportDetailTicketStatusReport != null && reportDetailTicketStatusReport.Count > 0)
                    {
                        ExporttoExcel(reportDetailTicketStatusReport, "Report", "AgentDetailTicketStatusReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 2)
                {
                    var reportCategoryWiseTicketStatuReport = _exportReport.GetCategoryWiseTicketStatusReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.CategoryId);

                    if (reportCategoryWiseTicketStatuReport != null && reportCategoryWiseTicketStatuReport.Count > 0)
                    {
                        ExporttoExcel(reportCategoryWiseTicketStatuReport, "Report", "CategoryWiseTicketStatusReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 3)
                {
                    var reportTicketOverduesbyCategorReport = _exportReport.GetTicketOverduesbyCategoryReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.OverdueTypeId, reportViewModel.CategoryId);

                    if (reportTicketOverduesbyCategorReport != null && reportTicketOverduesbyCategorReport.Count > 0)
                    {
                        ExporttoExcel(reportTicketOverduesbyCategorReport, "Report", "TicketOverduesReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 4)
                {
                    var reportTicketOverdueReport = _exportReport.GetTicketOverduesbyCategoryReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.OverdueTypeId, reportViewModel.CategoryId);

                    if (reportTicketOverdueReport != null && reportTicketOverdueReport.Count > 0)
                    {
                        ExporttoExcel(reportTicketOverdueReport, "Report", "TicketOverduesReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 5)
                {
                    var reportEscalationReport = _exportReport.GetEscalationbyCategoryReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.CategoryId);

                    if (reportEscalationReport != null && reportEscalationReport.Count > 0)
                    {
                        ExporttoExcel(reportEscalationReport, "Report", "EscalationbyCategoryReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 6)
                {
                    var reportDeletedReport = _exportReport.GetDeletedTicketHistoryByCategoryReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.CategoryId);

                    if (reportDeletedReport != null && reportDeletedReport.Count > 0)
                    {
                        ExporttoExcel(reportDeletedReport, "Report", "DeletedTicketHistoryByCategoryRepor.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 7)
                {
                    var reportPriorityReport = _exportReport.GetPriorityWiseTicketStatusReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.PriorityId);

                    if (reportPriorityReport != null && reportPriorityReport.Count > 0)
                    {
                        ExporttoExcel(reportPriorityReport, "Report", "PriorityWiseTicketStatusReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }

                if (reportViewModel.ReportId == 8)
                {
                    var reportUserReport = _exportReport.GetUsersDetailsReport(
                        reportViewModel.AgentId
                        );

                    if (reportUserReport != null && reportUserReport.Count > 0)
                    {
                        ExporttoExcel(reportUserReport, "Report", "UsersDetailsReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }
                if (reportViewModel.ReportId == 9)
                {
                    var checkinCheckOutReport = _exportReport.UserWiseCheckinCheckOutReport(
                        reportViewModel.Fromdate,
                        reportViewModel.Todate, reportViewModel.AgentId
                        );

                    if (checkinCheckOutReport != null && checkinCheckOutReport.Count > 0)
                    {
                        ExporttoExcel(checkinCheckOutReport, "Report", "UserWiseCheckinCheckOutReport.xlsx");
                    }
                    else
                    {
                        TempData["ReportMessages"] = "No Data to Export";
                    }
                }
            }

            reportViewModel.ListofCategory     = _category.GetAllActiveSelectListItemCategory();
            reportViewModel.ListofReport       = ReportList();
            reportViewModel.ListofOverdueTypes = _overdueTypes.GetAllActiveOverdueTypes();
            reportViewModel.ListofPriority     = _priority.GetAllPrioritySelectListItem();
            reportViewModel.ListofAgent        = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "",
                    Text  = "-----Select-----"
                }
            };
            return(View(reportViewModel));
        }