Пример #1
0
        public ActionResult AllDispatches()
        {
            var regService = ServiceCreator.GetRegistrationService();
            var account    = regService.FindAccount(User.Identity.Name);

            if (account != null)
            {
                var service          = ServiceCreator.GetDispatchesService();
                var activeDispatches = service.GetActiveDispatches(account.Id);
                var oldDispatches    = service.GetInActiveDispatches(account.Id);

                var model = new DispatchListViewModel();
                model.ActiveDispatches   = Mapper.Map <List <DispatchViewModel> >(activeDispatches);
                model.InActiveDispatches = Mapper.Map <List <DispatchViewModel> >(oldDispatches);

                return(View("DispatchCardList", model));
            }
            else
            {
                var model = new DispatchListViewModel();
                model.ActiveDispatches   = new List <DispatchViewModel>();
                model.InActiveDispatches = new List <DispatchViewModel>();

                return(View("DispatchCardList", model));
            }
        }
Пример #2
0
        public bool Login(string login, string password)
        {
            var hash = Encrypt(password);

            var service = ServiceCreator.GetRegistrationService();
            var account = service.FindAccount(login);

            return(account != null && account.PasswordHash == hash);
        }
Пример #3
0
        public void Register(string login, string password)
        {
            var hash    = Encrypt(password);
            var account = new ManagerAccount {
                Id = Guid.NewGuid(), PasswordHash = hash, Login = login
            };

            var service = ServiceCreator.GetRegistrationService();

            service.CreateAccount(account);
            service.CreateConfig(account.Id);
        }
Пример #4
0
        public Config FindConfiguration(string login)
        {
            var service = ServiceCreator.GetRegistrationService();
            var acc     = service.FindAccount(login);

            if (acc != null)
            {
                return(service.FindConfig(acc.Id));
            }
            else
            {
                throw new AuthException("Account not found");
            }
        }
Пример #5
0
        public void UpdateConfiguration(Config config)
        {
            var service = ServiceCreator.GetRegistrationService();

            service.UpdateConfig(config);
        }
Пример #6
0
        public ManagerAccount FindAccount(string login)
        {
            var service = ServiceCreator.GetRegistrationService();

            return(service.FindAccount(login));
        }