Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                DapperConfiguration.Initialize();
                ConnectionProvider provider = new ConnectionProvider();
                UserAccountDapper  dapper   = new UserAccountDapper();

                // UserAccountBroker userDataBroker = new UserAccountBroker(provider);
                //UserAccount user = userDataBroker.GetUserAccount("florian", "pwd");
                UserAccount user = null;
                IEnumerable <UserAccount> accounts = dapper.GetAllContact(provider.GetConnection(), 1);

                user = dapper.GetUserAccount(provider.GetConnection(), "florian", "pwd");

                if (user != null)
                {
                    Console.WriteLine(user.Firstname);
                    Console.WriteLine(user.Lastname);
                }
                else
                {
                    Console.WriteLine("Not found");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
            Console.Read();
        }
Exemplo n.º 2
0
        public UserAccount Register(string username, string password, string firstname, string lastname)
        {
            UserAccount userAccount = _userAccountDapper.GetUserAccount(_dbConnection, username, password);

            if ((userAccount.Username != null) && (userAccount.Password != null))
            {
                throw new Exception("User exist already!");
            }
            else if (userAccount.Username != null)
            {
                throw new Exception("Username is already used, pleas choose anotherone");
            }
            else if (userAccount.Password != null)
            {
                throw new Exception("Please enter a valide password!");
            }
            else
            {
                return(null);
            }
        }