public User GetClient(User user)
        {
            User returnedUser = new User();
            try
            {
                String procName = "checkUser";
                this._conn = new MySqlConnection(this._connectionString);
                this._conn.Open();

                MySqlCommand command = new MySqlCommand(procName, _conn);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@username", user.userName);
                command.Parameters.AddWithValue("@pswd", user.userPassword);
                MySqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    returnedUser.Id = Int32.Parse(dr.GetString(0));
                    returnedUser.userName = dr.GetString(1);
                    returnedUser.userPassword = dr.GetString(2);
                    returnedUser.userRole = dr.GetString(3);
                }
                _conn.Close();
            }
            catch
            {
                returnedUser = null;

            }
            return returnedUser;
        }
Example #2
0
 public User GetPackages(User user)
 {
     ClientDataAccess clientDataAccess = new ClientDataAccess();
     var clientPackges = clientDataAccess.GetClientPackeges(user);
     user.userPackages = clientPackges;
     return user;
 }
        public List<Package> GetClientPackeges(User client)
        {
            List<Package> userPackages = new List<Package>();
            Package returnedPackage = new Package();
            try
            {
                String procName = "getAllUsers";
                _conn = new MySqlConnection(_connectionString);
                _conn.Open();

                MySqlCommand command = new MySqlCommand(procName, _conn);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@usernames", client.userName);
                MySqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    returnedPackage = new Package();
                    returnedPackage._sender      = dr.GetString(5);
                    returnedPackage._receiver    = dr.GetString(6);
                    returnedPackage._name        = dr.GetString(7);
                    returnedPackage._description = dr.GetString(8);
                    returnedPackage._senderCity  = dr.GetString(9);
                    returnedPackage._destionationCity = dr.GetString(10);
                    returnedPackage._tracking         = dr.GetBoolean(11);

                    userPackages.Add(returnedPackage);

                }
                _conn.Close();
            }
            catch
            {
                Console.WriteLine("Package read error");

            }

            return userPackages;
        }
 public void GetClientPackages(User user)
 {
     throw new NotImplementedException();
 }
 public User GetClient(User user)
 {
     ClientBL clientBL = new ClientBL();
     return clientBL.GetClient(user);
 }
 public void Edit(User user)
 {
 }
 public void AddUser(User user)
 {
     ClientBL clientBL = new ClientBL();
     clientBL.RegisterUser(user);
 }
        public void RegisterUser(User user)
        {
            String procName = "RegisterUser";
            this._conn = new MySqlConnection(this._connectionString);
            this._conn.Open();

            MySqlCommand command = new MySqlCommand(procName, _conn);
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@username", user.userName);
            command.Parameters.AddWithValue("@pswd", user.userPassword);
            MySqlDataReader dr = command.ExecuteReader();
            _conn.Close();
        }
Example #9
0
 public void RegisterUser(User user)
 {
     ClientDataAccess clientDataAccess = new ClientDataAccess();
     clientDataAccess.RegisterUser(user);
 }
Example #10
0
 public User GetClient(User user)
 {
     ClientDataAccess clientDataAccess = new ClientDataAccess();
     var client = clientDataAccess.GetClient(user);
     return client;
 }