Example #1
0
        /*  -----------------------------------------------------
         *  FUNCTION - DeleteUser
         *  -----------------------------------------------------
         *
         * ------------------------------------------------------
         */
        public void DeleteUser(Cp_user user)
        {
            cpdb.Cp_Users.Remove((
                                     from u in cpdb.Cp_Users
                                     where u.Cp_user_id == user.Cp_user_id
                                     select u
                                     ).FirstOrDefault());

            cpdb.SaveChanges();
        }
Example #2
0
 public Cp_user InsertUser(string firstName, string clientName, string lastName, string username, string password, string userRole)
 {
     if (!VerifyExistingUser(username))
     {
         Cp_user newUser = BuildNewUser(firstName, lastName, clientName, username, password, userRole);
         return(UserSQL.InsertUser(newUser));
     }
     else
     {
         return(null);
     }
 }
Example #3
0
        public Cp_user UpdateUser(Cp_user userToUpdate, Cp_user userNewInfo)
        {
            userToUpdate.Client_id     = userNewInfo.Client_id;
            userToUpdate.First_name    = userNewInfo.First_name;
            userToUpdate.Last_name     = userNewInfo.Last_name;
            userToUpdate.Username      = userNewInfo.Username;
            userToUpdate.User_password = userNewInfo.User_password;
            userToUpdate.User_role_cd  = userNewInfo.User_role_cd;

            cpdb.SaveChanges();

            return(userToUpdate);
        }
Example #4
0
        public bool VerifyExistingUser(string username)
        {
            Cp_user tstUser = UserHand.SelectUser(username);

            if (tstUser == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #5
0
        public Cp_user DeleteUser(string username)
        {
            if (!VerifyExistingUser(username))
            {
                Cp_user user = UserSQL.SelectUser(username);
                UserSQL.DeleteUser(user);

                return(user);
            }
            else
            {
                return(null);
            }
        }
Example #6
0
 /*  -----------------------------------------------------
  *  FUNCTION - SelectUser
  *  -----------------------------------------------------
  *
  * ------------------------------------------------------
  */
 public Cp_user SelectUser(Cp_user user)
 {
     if (user == null)
     {
         return(null);
     }
     else
     {
         return((
                    from u in cpdb.Cp_Users
                    where u.Cp_user_id == user.Cp_user_id
                    select u
                    ).FirstOrDefault());
     }
 }
Example #7
0
        public Cp_user UpdateUser(string origUsername,
                                  string newClientName, string newFirstName, string newLastName, string newUsername, string newPassword, string newUserRole
                                  )
        {
            if (origUsername != newUsername)
            {   //check to make sure you aren't changing it to an existing username
                if (!VerifyExistingUser(newUsername))
                {
                    return(null);
                }
            }
            else
            {
                Cp_user origUser    = UserSQL.SelectUser(origUsername);
                Cp_user newUserInfo = BuildNewUser(newFirstName, newLastName, newClientName, newUsername, newPassword, newUserRole);

                Cp_user updatedUser = UserSQL.UpdateUser(origUser, newUserInfo);
                return(updatedUser);
            }
            return(null);
        }
Example #8
0
        /*  -----------------------------------------------------
         *  FUNCTION - InsertUser
         *  -----------------------------------------------------
         *
         * ------------------------------------------------------
         */
        public Cp_user InsertUser(Cp_user user)
        {
            var tstUser = (
                from u in cpdb.Cp_Users
                where u.Cp_user_id == user.Cp_user_id
                select u
                ).FirstOrDefault();

            Cp_user newUser;

            if (tstUser == null)
            {
                newUser = cpdb.Cp_Users.Add(user);
                cpdb.SaveChanges();
            }
            else
            {
                newUser = tstUser;
            }

            return(newUser);
        }