Esempio n. 1
0
        public Museum GetByLogin(string login)
        {
            musariumRepository.OpenConnection();
            var res = musariumRepository.GetMuseumByLogin(login);

            musariumRepository.CloseConnection();
            return(res);
        }
Esempio n. 2
0
        public AuthenticationResult Login(string login, string password)
        {
            var result = musariumMusariumRepository.OpenConnection();

            cityRepository.OpenConnection();
            if (result != false)
            {
                var museum = musariumMusariumRepository.GetMuseumByLogin(login);
                if (museum == null)
                {
                    musariumMusariumRepository.CloseConnection();
                    return(AuthenticationResult.IsNotExist);
                }
                else if (museum.Login != login)
                {
                    musariumMusariumRepository.CloseConnection();
                    return(AuthenticationResult.IncorrectLogin);
                }
                else if (museum.Password != password)
                {
                    musariumMusariumRepository.CloseConnection();
                    return(AuthenticationResult.IncorrectPassword);
                }
                else
                {
                    AppData.CurrentMuseum = museum;
                    museum.CityName       = cityRepository.GetMuseumCityById(museum.CityId).Name;
                    musariumMusariumRepository.CloseConnection();
                    return(AuthenticationResult.Successful);
                }
            }
            else
            {
                cityRepository.CloseConnection();
                musariumMusariumRepository.CloseConnection();
                return(AuthenticationResult.InvalidConnection);
            }
        }