static void Main(string[] args) { User x; var user = new User("Rafael", "*****@*****.**"); user.SetPassword("teste123!@", "teste123!@"); user.Validate(); using (IUserRepository repo = new UserRepository(new AppDataContext())) { repo.Create(user); } using (IUserRepository repo = new UserRepository(new AppDataContext())) { x = repo.Get("*****@*****.**"); Console.WriteLine(x.Name); } Console.ReadKey(); //using (IUserRepository repo = new UserRepository(new AppDataContext())) //{ // repo.Delete(x); //} }
public void Register(string name, string email, string password, string confirmPassword) { var hasUser = _repository.Get(email); // Caso existisse rules, já buscaria no mesmo select (2 selects = menos performance) if (hasUser != null) throw new Exception(Errors.DuplicateEmail); var user = new User(name, email); user.SetPassword(password, confirmPassword); _repository.Create(user); }
public void Register(string name, string email, string password, string confirmPassword) { var hasUser = _repository.Get(email); if (hasUser != null) throw new Exception(Errors.DuplicateEmail); var user = new User(name, email); user.SetPassword(password, confirmPassword); user.Validate(); _repository.Create(user); }