/**********************CUSTOMER REPORT SECTION***************************/ /// <summary> /// Method which displays report info about a customer /// displays buttons which allows the manager to transform this view into an customer report /// </summary> /// <param name="searchString">filter which may be applied to the order list</param> /// <returns>a custoemr to the view</returns> public ActionResult CustomerReport(string id) { if (id != null) { var user = uow.UserRepository.Get(m => m.Id.Equals(id, StringComparison.CurrentCultureIgnoreCase)); decimal totalSpent = 0.00m; foreach (var o in user.Order) { totalSpent += o.Total; } CustomerReportViewModel crvm = new CustomerReportViewModel { FirstName = user.FName, LastName = user.LName, OrderCount = user.Order.Count, NumberOfFines = user.Fines.Count, TotalSpent = totalSpent, Username = user.UserName, City = user.City, Address = user.Address, Postcode = user.PostalCode }; return(View(crvm)); } else { return(View()); } }
/// <summary> /// Method which generates a PDF report from data in the CustomerReport view /// </summary> /// <param name="username">filter which may be applied to customer</param> /// <returns>A PDF with the contents of the report</returns> public ActionResult GenerateCustomerPDF(string username) { var user = uow.UserRepository.Get(m => m.UserName.Equals(username, StringComparison.CurrentCultureIgnoreCase)); decimal totalSpent = 0.00m; foreach (var o in user.Order) { totalSpent += o.Total; } CustomerReportViewModel crvm = new CustomerReportViewModel { FirstName = user.FName, LastName = user.LName, OrderCount = user.Order.Count, NumberOfFines = user.Fines.Count, TotalSpent = totalSpent, Username = user.UserName, City = user.City, Address = user.Address, Postcode = user.PostalCode }; return(new ViewAsPdf("CustomerReport", crvm) { FileName = "CustomerReport.pdf", CustomSwitches = " --footer-center \"Page [page] of [toPage]\"" }); }
//Customer Reports Stuff //select list private async Task <SelectList> GetAllUsers() { //Get the list of users from the database List <CustomerReportViewModel> customerList = new List <CustomerReportViewModel>(); List <Int32> customerIDList = new List <Int32>(); Int32 count = 0; foreach (AppUser user in _userManager.Users) { if (await _userManager.IsInRoleAsync(user, "Customer") == true) //user is in the role { //add user to list of members CustomerReportViewModel newcus = new CustomerReportViewModel(); newcus.SelectCustomerName = user.Email; newcus.SelectCustomerID = count; customerIDList.Add(count); customerList.Add(newcus); count += 1; } } SelectList customerSelectList = new SelectList(customerList, "SelectCustomerID", "SelectCustomerName"); return(customerSelectList); }
public async Task <IActionResult> Order(CustomerReportViewModel viewModel) { var customer = new Customer { CustomerDate = viewModel.CustomerDate, NumOfGuests = viewModel.NumOfGuests }; var custInfo = new CustInfo { LastName = viewModel.LastName, FirstName = viewModel.FirstName, Email = viewModel.Email, PhoneNumber = viewModel.PhoneNumber }; var special = new Special { NumOfGuests = viewModel.NumOfGuests, Reasons = viewModel.Reasons, Other = viewModel.Other }; if (ModelState.IsValid) { _context.Add(customer); _context.Add(custInfo); _context.Add(special); await _context.SaveChangesAsync(); return(RedirectToAction("Report", "Home")); } return(View(viewModel)); }
public async Task <IActionResult> CustomerSearch() { ViewBag.AllCustomers = await GetAllUsers(); CustomerReportViewModel crvm = new CustomerReportViewModel(); return(View(crvm)); }
public ActionResult Add(int id) { var report = reportRepository.Get(id); var customerReportViewModel = new CustomerReportViewModel(); customerReportViewModel.Report = report; customerReportViewModel.ReportId = report.Id; customerReportViewModel.Customers = customerRepository.GetAll().ToList(); return(View(customerReportViewModel)); }
public ActionResult Customer() { var orderedUsers = _usersManagement.GetOrderedUsersList(); var usersToShow = GenerateUsersToShowList(orderedUsers); var customerReportViewModel = new CustomerReportViewModel { Customer = new User(), UsersToShowList = usersToShow, }; return(View(customerReportViewModel)); }
public ActionResult Add(CustomerReportViewModel customerReportViewModel) { if (ModelState.IsValid) { var customerReport = new CustomerReport(); customerReport.ReportId = customerReportViewModel.ReportId; customerReport.CustomerId = customerReportViewModel.CustomerId; customerReport.CubeName = customerReportViewModel.CubeName; customerReport.ServerName = customerReportViewModel.ServerName; customerReport.DBName = customerReportViewModel.DBName; customerReport.DBType = customerReportViewModel.DBType; customerReportRepository.Add(customerReport); return(RedirectToAction("Details", "Report", new { id = customerReportViewModel.ReportId })); } return(View(customerReportViewModel)); }
public async Task <ActionResult> ReHireEmployeesIndex(CustomerReportViewModel crvm) { List <CustomerReportViewModel> customerList = new List <CustomerReportViewModel>(); foreach (AppUser user in _userManager.Users) { if (await _userManager.IsInRoleAsync(user, "Employee") == true) //user is in the role { CustomerReportViewModel newcus = new CustomerReportViewModel(); newcus.SelectCustomerName = user.Email; customerList.Add(newcus); } } AppUser customer = _userManager.Users.Where(u => u.Email == customerList[crvm.SelectedCustomerID].SelectCustomerName).First(); customer.EStatus = EmploymentStatus.Hired; return(View("ConfirmFire", customer)); }
public ActionResult Customer(CustomerReportViewModel reportViewModel) { var transactionsList = _transactionsManagement.GetTransactions(reportViewModel.Customer, reportViewModel.BeginningDate, reportViewModel.EndingDate); var tList = ReportInfoFromList(transactionsList); using (var excelPackage = new ExcelPackage()) { var worksheet = excelPackage.Workbook.Worksheets.Add("Primera Hoja"); //Here we have to select one of the following options: Manual or Auto writting //With the auto option, we should create a new class to avoid the complex objects mapping problems //instead of using the simple Transaction Class //1. Manual worksheet.Cells["A1"].Value = CODIGO_FACTURA; worksheet.Cells["B1"].Value = MONTO; worksheet.Cells["C1"].Value = PUNTOS; worksheet.Cells["D1"].Value = CODIGO_SAR; worksheet.Cells["E1"].Value = NOMBRE_VENDEDOR; worksheet.Cells["F1"].Value = FECHA; //worksheet.Cells["G1"].Value = TIENDA; worksheet.Cells["G1"].Value = COMPANIA; /* * int i = 2; * foreach (var transaction in transactionsList) * { * worksheet.Cells["A" + i].Value = transaction.Amount; * worksheet.Cells["B" + i].Value = transaction.Amount; * i++; * } */ //2. Automatic if (tList != null && tList.Count() != 0) { worksheet.Cells["A2"].LoadFromCollection(tList); } return(File(excelPackage.GetAsByteArray(), "application/vnd.ms-excel", "a_cool_name.xls")); } }
public async Task <IActionResult> AggregateCustomerReport() { List <CustomerReportViewModel> customerList = new List <CustomerReportViewModel>(); foreach (AppUser user in _userManager.Users) { if (await _userManager.IsInRoleAsync(user, "Customer") == true) //user is in the role { CustomerReportViewModel newcus = new CustomerReportViewModel(); newcus.SelectCustomerName = user.Email; customerList.Add(newcus); } } foreach (CustomerReportViewModel c in customerList) { //AppUser customer = _userManager.Users.Where(u => u.Email == customerList[c.SelectedCustomerID].SelectCustomerName).First(); List <Order> orders = _context.Orders.Include(o => o.Discount) .Include(o => o.Tickets) .ThenInclude(t => t.Showing) .ThenInclude(s => s.Movie) .Include(o => o.Tickets) .ThenInclude(t => t.Showing) .ThenInclude(s => s.Price).Where(o => o.Customer.UserName == c.SelectCustomerName).ToList(); foreach (Order order in orders) { if (order.OrderHistory == OrderHistory.Past) { if (order.PopcornPointsUsed == false) { c.TotalRevenue += order.PostDiscount; } else if (order.PopcornPointsUsed == true) { c.PopcornPointsUsed += (order.Tickets.Count() * 100); } c.SeatsSold += order.Tickets.Count(); } } } return(View(customerList)); }