コード例 #1
0
ファイル: UtenteManager.cs プロジェクト: themarcuz/BusBook
 public void Save(Utente utente)
 {
     if (utente.Id != 0 && utente.Agenzia == null)
     {
         AgenziaRepository ar = new AgenziaRepository();
         utente.Agenzia = ar.GetAgenziaByIdUtente(utente.Id);
         UtenteRepository ur = new UtenteRepository();
         ur.Save(utente);
     }
 }
コード例 #2
0
ファイル: LoginHelper.cs プロジェクト: themarcuz/BusBook
        public static AuthenticationResult AuthenticateUtente(String username, String passwordInChiaro)
        {
            AuthenticationResult result = null;

            UtenteRepository ur = new UtenteRepository();
            var registeredUtente = ur.GetByUsername(username);

            if (registeredUtente == null)
            {
                result = new AuthenticationResult { IsAuthenticated = false, AuthErrorMessage = "Username/Password errata!" };
            }
            else
            {
                CryptoHelper crypter = new CryptoHelper();
                if (crypter.cryptPassword(passwordInChiaro).Equals(registeredUtente.Password))
                    result = new AuthenticationResult { IsAuthenticated = true, AuthenticatedUtente = registeredUtente };
                else
                    result = new AuthenticationResult { IsAuthenticated = false, AuthErrorMessage = "Username/Password errata!"};

            }

            return result;
        }