public static void ReadInput() { ReportsFactory revenueReportFactory = new ReportsFactory(); Console.WriteLine("\r\n$$$$$$$$$$$$$$$$$$$$$$$$"); Console.WriteLine("Product Revenue"); Console.WriteLine("$$$$$$$$$$$$$$$$$$$$$$$$$"); List <Report> ProductRevenueReports = new List <Report>(); ProductRevenueReports = revenueReportFactory.GetRevenueByProduct(); Console.WriteLine("Product Revenue"); foreach (Report report in ProductRevenueReports) { Console.WriteLine($"{report.Name} ${report.Price}"); } Console.WriteLine("\r\nPress any key to return to main menu"); Console.ReadLine(); }
//Method Name: ReadInput //Purpose of the Method: This method selects a list of Reports displaying the amount of revenue generated for a customer and iterates over them to write the reports to the console. public static void ReadInput() { ReportsFactory revenueReportFactory = new ReportsFactory(); Console.WriteLine("\r\n######################"); Console.WriteLine("REVENUE BY CUSTOMER"); Console.WriteLine("######################"); List <Report> CustomerRevenueReports = new List <Report>(); CustomerRevenueReports = revenueReportFactory.GetRevenueByCustomer(); Console.WriteLine($"Customer Revenue"); foreach (Report report in CustomerRevenueReports) { Console.WriteLine($"{report.Name,-10} ${report.Price,-30}"); } Console.WriteLine("\r\nPress any key to return to main menu"); Console.ReadLine(); }
public IHttpActionResult SalesReport(string user, string fromDate, string toDate) { var repo = ReportsFactory.GetRepo(); DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); if (fromDate != null) { if (fromDate.Length < 6 || fromDate.Length > 10) { Exception ex = new Exception(); return(BadRequest(ex.Message)); } } if (toDate != null) { if (toDate.Length < 6 || toDate.Length > 10) { Exception ex = new Exception(); return(BadRequest(ex.Message)); } } if (fromDate != null) { if (fromDate.Length >= 6 || fromDate.Length <= 10) { var chkYrFromDate = fromDate.Substring(fromDate.Length - 4); if (int.Parse(chkYrFromDate) > DateTime.Now.Year) { Exception ex = new Exception(); return(BadRequest(ex.Message)); } } } if (toDate != null) { if (toDate.Length >= 6 || toDate.Length <= 10) { var chkYrToDate = toDate.Substring(toDate.Length - 4); if (int.Parse(chkYrToDate) > DateTime.Now.Year) { Exception ex = new Exception(); return(BadRequest(ex.Message)); } } } if (fromDate == null) { startDate = new DateTime(1970, 1, 1); } else { startDate = DateTime.Parse(fromDate); } if (toDate == null) { endDate = new DateTime(2150, 1, 1); } else { endDate = DateTime.Parse(toDate); } try { var result = repo.GetSalesReports(user, startDate, endDate); if (result.Count == 0) { return(NotFound()); } return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult GetReportForm(ReportType type) { var currentView = ReportsFactory.GetReportFormView(type); return(PartialView(currentView)); }