예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                var accServ     = new AccountsService();
                var banksServ   = new BanksService();
                var clientsServ = new ClientsService();
                var transServ   = new TransactionsService();
                var timer       = new FutureTimer();

                var system = new BankingSystem(banksServ, clientsServ, accServ, transServ, timer);
                system.CreateBank("MyBank", 5, 500, 1000, 12);
                system.CreateBank("AnotherBank", 3, 100, 500, 6);
                system.CreateBank("TheLastButTheBest", 10, 50, 1200, 5);
                system.CreateClient("Max", "Reshetnikov", new PassportData(), "address");
                system.CreateAccount("MyBank", "Max", "Reshetnikov",
                                     AccountFactoryTypes.Credit, 1000);
                system.CreateAccount("AnotherBank", "Max", "Reshetnikov",
                                     AccountFactoryTypes.Deposit, 500);
                system.CreateAccount("TheLastButTheBest", "Max", "Reshetnikov",
                                     AccountFactoryTypes.Debit, 2000);

                var accId1 = system.GetAccId("Max", "Reshetnikov", "MyBank");
                system.PutMoney(accId1, 5000);
                Console.WriteLine(system.CheckBalance(accId1) == 6000);
                system.WithdrawMoney(accId1, 6500);
                Console.WriteLine(system.CheckBalance(accId1) == -500);
                system.GetCommission(accId1);
                Console.WriteLine(system.CheckBalance(accId1) == -1000);
                system.GetCommission(accId1);
                Console.WriteLine(system.CheckBalance(accId1) == -1000);
                var accId2 = system.GetAccId("Max", "Reshetnikov", "AnotherBank");
                system.PutMoney(accId1, 5000);
                system.TransferMoney(accId1, accId2, 2000);
                Console.WriteLine(system.CheckBalance(accId2) == 2500);

                for (var i = 0; i <= 31; ++i)
                {
                    system.PutInterestMoney(accId2);
                    system.Timer.NextDay();
                }

                Console.WriteLine(system.CheckBalance(accId2));
                var accId3 = system.GetAccId("Max", "Reshetnikov", "TheLastButTheBest");

                for (var i = 0; i <= 31; ++i)
                {
                    system.PutInterestMoney(accId3);
                    system.Timer.NextDay();
                }

                Console.WriteLine(system.CheckBalance(accId3));

                system.CreateClient("Tany", "Kolobova");
                system.CreateAccount("MyBank", "Tany", "Kolobova", AccountFactoryTypes.Credit, 2500);
                var accId4 = system.GetAccId("Tany", "Kolobova", "MyBank");
                system.WithdrawMoney(accId4, 2000);
                Console.WriteLine(system.CheckBalance(accId4) == 2500);
                system.UpdateClientsAddress("Tany", "Kolobova", "address");
                system.UpdatePassportData("Tany", "Kolobova", new PassportData());
                system.WithdrawMoney(accId4, 2000);
                Console.WriteLine(system.CheckBalance(accId4) == 500);
                system.CancelTrans(system.TransServ.GetEnumerator().Last().TransId);
                Console.WriteLine(system.CheckBalance(accId4) == 2500);
            }
            catch (BanksManagerException e)
            {
                Console.Error.WriteLine(e.Message);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var timer           = new FutureTimer();
            var commitRepo      = new CommitsRepository();
            var employeeRepo    = new EmployeeRepository();
            var tasksRepo       = new TasksRepository();
            var dailyReportRepo = new DailyReportRepo();
            var sprintRepo      = new SprintReportRepo();
            var teamLeaderRepo  = new TeamLeaderReportRepo();

            var database = new UnitOfWork(timer, commitRepo, employeeRepo,
                                          tasksRepo, dailyReportRepo, sprintRepo, teamLeaderRepo);

            var commitServ   = new CommitService(database);
            var employeeServ = new EmployeeService(database);
            var reportServ   = new ReportService(database);
            var tasksServ    = new TasksService(database);
            var timerServ    = new TimerService(database);

            var commitContr   = new CommitController(commitServ);
            var employeeContr = new EmployeeController(employeeServ);
            var reportContr   = new ReportController(reportServ);
            var tasksContr    = new TasksController(tasksServ);
            var timerContr    = new TimerController(timerServ);

            employeeContr.SetTeamLeader("Max");
            employeeContr.AddEmployee("Cyrill");
            employeeContr.AddEmployee("Egor");

            employeeContr.UpdateSuperior("Cyrill", "Max");
            employeeContr.UpdateSuperior("Egor", "Max");
            employeeContr.ShowHierarchy();

            reportContr.CreateDailyReport(employeeContr.GetId("Egor"));
            reportContr.CreateDailyReport(employeeContr.GetId("Cyrill"));


            tasksContr.Create("Task1", employeeContr.GetId("Cyrill"));
            tasksContr.Create("Task2", employeeContr.GetId("Cyrill"));
            tasksContr.Create("Task3", employeeContr.GetId("Egor"));
            tasksContr.Create("Task4", employeeContr.GetId("Egor"));

            tasksContr.UpdateComment("Task1", "MUST-DO");
            tasksContr.UpdateEmployee("Task2", employeeContr.GetId("Egor"));

            var task = tasksContr.GetTaskById(tasksContr.GetIdByName("Task4"));

            Console.WriteLine(task.Name == "Task4");
            task = tasksContr.GetTaskByLastCommit();
            Console.WriteLine(task.Name == "Task2");
            task = tasksContr.GetLastCreatedTask();
            Console.WriteLine(task.Name == "Task4");
            var tasks = tasksContr.GetTasksOfEmployee(employeeContr.GetId("Cyrill"));

            Console.WriteLine(tasks[0].EmployeeInChargeId == employeeContr.GetId("Cyrill"));
            tasks = tasksContr.GetEditedTasks();
            Console.WriteLine(tasks[0].Edited());
            tasks = tasksContr.GetTasksOfSubordinates(employeeContr.GetId("Max"));
            Console.WriteLine(tasks.Count == 4);

            reportContr.AddDailyTasks(employeeContr.GetId("Egor"),
                                      tasksContr.GetDailyTaskOfEmployee(employeeContr.GetId("Egor")));
            reportContr.AddDailyChanges(employeeContr.GetId("Egor"),
                                        commitContr.GetDailyCommitsOfEmployee(employeeContr.GetId("Egor")));
            reportContr.CompleteReport(reportServ.GetLastDailyReportIdOfEmployee(employeeContr.GetId("Egor")));


            reportContr.AddDailyTasks(employeeContr.GetId("Cyrill"),
                                      tasksContr.GetDailyTaskOfEmployee(employeeContr.GetId("Cyrill")));
            reportContr.AddDailyChanges(employeeContr.GetId("Cyrill"),
                                        commitContr.GetDailyCommitsOfEmployee(employeeContr.GetId("Cyrill")));
            reportContr.CompleteReport(reportServ.GetLastDailyReportIdOfEmployee(employeeContr.GetId("Cyrill")));

            timerContr.NextDay();

            tasksContr.Create("Task5", employeeContr.GetId("Max"));
            tasksContr.Create("Task6", employeeContr.GetId("Cyrill"));
            tasksContr.UpdateComment("Task5", "New Task");
            tasksContr.UpdateComment("Task6", "Important");

            reportContr.AddDailyTasks(employeeContr.GetId("Egor"),
                                      tasksContr.GetDailyTaskOfEmployee(employeeContr.GetId("Egor")));
            reportContr.AddDailyChanges(employeeContr.GetId("Egor"),
                                        commitContr.GetDailyCommitsOfEmployee(employeeContr.GetId("Egor")));
            reportContr.CompleteReport(reportServ.GetLastDailyReportIdOfEmployee(employeeContr.GetId("Egor")));


            reportContr.AddDailyTasks(employeeContr.GetId("Cyrill"),
                                      tasksContr.GetDailyTaskOfEmployee(employeeContr.GetId("Cyrill")));
            reportContr.AddDailyChanges(employeeContr.GetId("Cyrill"),
                                        commitContr.GetDailyCommitsOfEmployee(employeeContr.GetId("Cyrill")));
            reportContr.CompleteReport(reportServ.GetLastDailyReportIdOfEmployee(employeeContr.GetId("Cyrill")));

            reportContr.CreateSprintReport(2);
            reportContr.AddReportsToSprint(reportContr.GetLastSprint(),
                                           reportContr.GetReportsOfPeriod(2));
        }