Exemplo n.º 1
0
        public PassedList getPasses(int userID)
        {
            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = "TP_GetPasses";
            objCmd.Parameters.AddWithValue("@passedBy", userID);
            DataSet passesDS = objDB.GetDataSetUsingCmdObj(objCmd);

            PassedList passedList = new PassedList();

            if (passesDS.Tables[0].Rows.Count > 0)
            {
                if (objDB.GetField("Passed", 0) == DBNull.Value)
                {
                    return(null);
                }
                else
                {
                    passedList.List = passesDS.Tables[0].Rows[0]["Passed"].ToString().TrimEnd('|');
                    return(passedList);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public bool checkIfUserPassedOtherUser(string username1, string username2)
        {
            User tempUser = new User();
            int  userID1  = tempUser.getUserID(username1);
            int  userID2  = tempUser.getUserID(username2);

            PassedList tempList = new PassedList();

            try
            {
                string passedProfiles1 = tempList.getPasses(userID1).List;
                int[]  passedUserIDs1  = Array.ConvertAll(passedProfiles1.Split('|'), int.Parse);

                if (passedUserIDs1.Contains(userID2))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (NullReferenceException)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public int addPassToDB(int userID, int passedUserID)
        {
            int        result = 0;
            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;


            PassedList tempPasses = new PassedList();
            string     passList;
            User       tempUser = new User();

            //int passedUserID = tempUser.getUserID(passedProfile);
            try
            {
                passList  = tempPasses.getPasses(userID).List;
                passList += "|" + passedUserID + "|";

                objCmd.CommandText = "TP_ModifyPasses";
                objCmd.Parameters.AddWithValue("@passed", passList);
                objCmd.Parameters.AddWithValue("@passedBy", userID);
                result = objDB.DoUpdateUsingCmdObj(objCmd);
            }
            catch (NullReferenceException)
            {
                //list of passed list is empty, so add the first pass
                passList           = passedUserID + "|";
                objCmd.CommandText = "TP_AddPass";
                objCmd.Parameters.AddWithValue("@passed", passList);
                objCmd.Parameters.AddWithValue("@passedBy", userID);
                result = objDB.DoUpdateUsingCmdObj(objCmd);
            }
            return(result);
        }