예제 #1
0
        public DataManager(string login, string password)
        {
            var _db = new ApiDb($"{Directory.GetCurrentDirectory()}/configs/db.json");

#if DEBUG
            try
            {
                _db.AddNewWorker(new Worker
                {
                    FirstName  = "A1",
                    MiddleName = "AA1",
                    LastName   = "AAA1",
                    Login      = "******",
                    Password   = "******",
                    Role       = Role.Technician
                });
                _db.AddNewWorker(new Worker
                {
                    FirstName  = "A2",
                    MiddleName = "AA2",
                    LastName   = "AAA2",
                    Login      = "******",
                    Password   = "******",
                    Role       = Role.Technician
                });
                _db.AddNewWorker(new Worker
                {
                    FirstName  = "A3",
                    MiddleName = "AA3",
                    LastName   = "AAA3",
                    Login      = "******",
                    Password   = "******",
                    Role       = Role.Manager
                });
            }
            catch
            {
            }
#endif

            auth = new SimpleAuthenticator(_db);

            if (!auth.Verify(login, password))
            {
                throw new AuthenticationException("Неверный логин или пароль");
            }

            _bh = new BehaviorFactory().Factory(login, _db);
        }