示例#1
0
        private static IList <User> CreateUsers(int count, EmergencyService service)
        {
            var users = new List <User>();

            for (int i = 0; i < count; i++)
            {
                var user = new User(service)
                {
                    Name = GetUserName()
                };
                users.Add(user);
            }
            return(users);
        }
示例#2
0
        static void Main(string[] args)
        {
            string         connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            CallRepository callRepository   = new CallRepository(connectionString);

            IList <IOperator> operators = new List <IOperator>
            {
                new Operator("Liza", callRepository),
                new Operator("Homer", callRepository),
                new Operator("Bart", callRepository)
            };

            Dictionary <DepartmentType, IDepartment> departments =
                new Dictionary <DepartmentType, IDepartment>();

            var fire    = new FireDepartment();
            var police  = new PoliceDepartment();
            var medical = new MedicalDepartment();

            departments.Add(DepartmentType.Fire, fire);
            departments.Add(DepartmentType.Police, police);
            departments.Add(DepartmentType.Medical, medical);

            var emergencyService = new EmergencyService(operators, departments);

            var users = CreateUsers(40, emergencyService);

            MakeRandomCall(users);

            while (true)
            {
                Thread.Sleep(3000);
                Console.Clear();

                var calls = callRepository.GetAll();

                foreach (var c in calls)
                {
                    Console.WriteLine($"Id: {c.Id}\tUserName: {c.UserName}\tIDepartment: {c.DepartmentName}" +
                                      $"\tOperatorName: {c.OperatorName}\tState: {c.State}");
                }
            }
        }
示例#3
0
 public User(EmergencyService emergencyService)
 {
     _emergencyService = emergencyService;
 }