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); } }
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; }