private void OnSortByNameCommand() { if (SelectedRequests != null) { SelectedRequests = ReportDataGenerator.Sort(SelectedRequests, nameof(Request.Name)); } }
private static void Main() { var db = new CompanyEntities(); using (db) { var random = new RandomGenerator(); var departments = new DepartmentsDataGenerator(); var projects = new ProjectsDataGenerator(); var employees = new EmployeesDataGenerator(); var reports = new ReportDataGenerator(); var employeesProjects = new EmployeesProjectsDataGenerator(); departments.Generate(db, random, 100); db.SaveChanges(); projects.Generate(db, random, 1000); db.SaveChanges(); employees.Generate(db, random, 5000); db.SaveChanges(); reports.Generate(db, random, 50); db.SaveChanges(); employeesProjects.Generate(db, random, 10); db.SaveChanges(); } }
public void AverageRequestTests() { var result = ReportDataGenerator.AverageRequests(requests); Assert.AreEqual(result, 41.83); result = ReportDataGenerator.AverageRequests(requests, "1"); Assert.AreEqual(result, 57.75); }
public void NoOfRequestGroupedByNameTests() { var result = ReportDataGenerator.NoOfRequestGroupedByName(requests); Assert.AreEqual(result, 3); result = ReportDataGenerator.NoOfRequestGroupedByName(requests, "1"); Assert.AreEqual(result, 2); }
public void NoOfUniqeRequestsTests() { var result = ReportDataGenerator.NoOfUniqeRequests(requests); Assert.AreEqual(result, 3); result = ReportDataGenerator.NoOfUniqeRequests(requests, "2"); Assert.AreEqual(result, 1); }
public void SumOfRequestsTests() { var result = ReportDataGenerator.SumOfRequestsPrice(requests, "1"); Assert.AreEqual(result, 115.5); result = ReportDataGenerator.SumOfRequestsPrice(requests, "2"); Assert.AreEqual(result, 10); }
public void GetRequestsTests() { var result = ReportDataGenerator.GetRequests(requests, "1"); Assert.AreEqual(result.Count, 3); result = ReportDataGenerator.GetRequests(requests, "2"); Assert.AreEqual(result.Count, 1); }
private void ShowRequests(string clientId = null) { if (clientId == null) { SelectedRequests = Requests; return; } SelectedRequests = ReportDataGenerator.GetRequests(Requests, clientId); }
private void OnRequestsInRangeCommand() { if (ValidateSelectedClientId()) { SelectedRequests = ReportDataGenerator.RequestsInRange(Requests, DoubleParse(MinPrice), DoubleParse(MaxPrice), SelectedClientId); SetSelectedReport(_communicationService.RequestsInRange(SelectedClientId, MinPrice, MaxPrice), ""); return; } SelectedRequests = ReportDataGenerator.RequestsInRange(Requests, DoubleParse(MinPrice), DoubleParse(MaxPrice)); SetSelectedReport(_communicationService.RequestsInRange(MinPrice, MaxPrice), ""); }
public void RequestsInRangeTests() { var result = ReportDataGenerator.RequestsInRange(requests, 40, 90); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 1); Assert.AreEqual(result[0].ClientId, "1"); Assert.AreEqual(result[0].Quantity, 5); result = ReportDataGenerator.RequestsInRange(requests, 5, 15); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 2); }
private void OnNoOfRequestCommand() { if (ValidateSelectedClientId()) { ShowRequests(SelectedClientId); int NoOfRequestsForClient = ReportDataGenerator.NoOfUniqeRequests(Requests, SelectedClientId); SetSelectedReport(_communicationService.UnigueRequests(SelectedClientId), NoOfRequestsForClient.ToString()); return; } ShowRequests(); int NoOfRequests = ReportDataGenerator.NoOfUniqeRequests(Requests); SetSelectedReport(_communicationService.UnigueRequests(), NoOfRequests.ToString()); }
private void OnTotalRequestsSumCommand() { double sum = 0; if (ValidateSelectedClientId()) { ShowRequests(SelectedClientId); sum = ReportDataGenerator.SumOfRequestsPrice(Requests, SelectedClientId); SetSelectedReport(_communicationService.SumOfRequests(SelectedClientId), sum.ToString()); return; } ShowRequests(); sum = ReportDataGenerator.SumOfRequestsPrice(Requests); SetSelectedReport(_communicationService.SumOfRequests(), sum.ToString()); }
private void OnAverageRequestValueCommand() { double Average = 0; if (ValidateSelectedClientId()) { ShowRequests(SelectedClientId); Average = ReportDataGenerator.AverageRequests(Requests, SelectedClientId); SetSelectedReport(_communicationService.AverageRequestsValue(SelectedClientId), Average.ToString()); return; } ShowRequests(); Average = ReportDataGenerator.AverageRequests(Requests); SetSelectedReport(_communicationService.AverageRequestsValue(), Average.ToString()); }
private void OnNoOfRequestGroupedByNameCommand() { int numberOfRequestName = 0; if (ValidateSelectedClientId()) { ShowRequests(SelectedClientId); numberOfRequestName = ReportDataGenerator.NoOfRequestGroupedByName(Requests, SelectedClientId); SetSelectedReport(_communicationService.RequestsGroupedByName(SelectedClientId), numberOfRequestName.ToString()); return; } ShowRequests(); numberOfRequestName = ReportDataGenerator.NoOfRequestGroupedByName(Requests); SetSelectedReport(_communicationService.RequestsGroupedByName(), numberOfRequestName.ToString()); }
private static void GenerateReportsScenario() { var setupAll = ReportDataGenerator.GenerateOverallReportData(10000, 50000, 50000, 50000, 50000, new DateTime(2010, 1, 1), new DateTime(2020, 8, 1)); AddSpecialUsers(setupAll); var transactionsSetup = setupAll.TransactionsSetup; setupAll.TransactionsSetup = new TransactionsSetup(); File.WriteAllText("setup.json", JsonConvert.SerializeObject(setupAll)); File.WriteAllText("transactions.json", JsonConvert.SerializeObject(transactionsSetup)); var userActivityReportScenario = ScenarioGenerator.UserActivityReportsScenario(setupAll, 1, 5, new DateTime(2010, 1, 1), new DateTime(2020, 8, 1)); File.WriteAllText("userActivityReportScenario.json", userActivityReportScenario); var overallReportScenario = ScenarioGenerator.OverallReportScenario(200, 1000, new DateTime(2010, 1, 1), new DateTime(2020, 8, 1), TimeSpan.FromDays(1050)); File.WriteAllText("overallReportScenario.json", overallReportScenario); }