Пример #1
0
        public DatingProfile loadDatingProfileFromDB(string userName, DatingProfile dateProfile)
        {
            //open the DB connection
            db.OpenConnection();

            //exec the query to the users dating Ad
            DataTable userInfo = db.ExecuteSQL("SELECT * FROM datingAds WHERE nickname='" + userName + "';");

            //assign all the vars in the class
            dateProfile.NickName      = userName;
            dateProfile.Sex           = (string)userInfo.Rows[0]["sex"];
            dateProfile.Max_Weight    = (int)userInfo.Rows[0]["max_weight"];
            dateProfile.Min_Weight    = (int)userInfo.Rows[0]["min_weight"];
            dateProfile.Max_Age       = (int)userInfo.Rows[0]["max_age"];
            dateProfile.Min_Age       = (int)userInfo.Rows[0]["min_age"];
            dateProfile.Race          = (int)(userInfo.Rows[0]["race"]);
            dateProfile.Hair          = (int)userInfo.Rows[0]["hair"];
            dateProfile.Max_Height_ft = (int)userInfo.Rows[0]["max_height_ft"];
            dateProfile.Min_Height_ft = (int)userInfo.Rows[0]["min_height_ft"];
            dateProfile.Max_Height_in = (int)userInfo.Rows[0]["max_height_in"];
            dateProfile.Min_Height_in = (int)userInfo.Rows[0]["min_height_in"];
            dateProfile.Interest1     = (int)userInfo.Rows[0]["interest_1"];
            dateProfile.Interest2     = (int)userInfo.Rows[0]["interest_2"];
            dateProfile.Interest3     = (int)userInfo.Rows[0]["interest_3"];

            //close the DB connection
            db.CloseConnection();

            //return a reference to the newly filled datingProfile
            return dateProfile;
        }
Пример #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dateProfile"></param>
 /// <returns></returns>
 public bool DeletedateingProfile(DatingProfile dateProfile)
 {
     int result = -1;
     string sql = string.Empty;
     string.Format("DELETE FROM [noIdeas].[dbo].[datingAds] WHERE username = '******'",dateProfile.NickName);
     try
     {
         db.OpenConnection();
         result = db.ExecuteSql(sql);
     }
     catch { }
     finally
     {
         db.CloseConnection();
     }
     if (result == 1)
         return true;
     else
         return false;
 }
Пример #3
0
 public bool UpdateDatingProfile(DatingProfile dprofile)
 {
     object[] results = this.Invoke("UpdateDatingProfile", new object[] {
                 dprofile});
     return ((bool)(results[0]));
 }
Пример #4
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateDatingProfile(DatingProfile dprofile, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateDatingProfile", new object[] {
                 dprofile}, callback, asyncState);
 }
Пример #5
0
 /// <remarks/>
 public void RunAndFindMatchesAsync(Profile profile, DatingProfile dprofile, object userState) {
     if ((this.RunAndFindMatchesOperationCompleted == null)) {
         this.RunAndFindMatchesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRunAndFindMatchesOperationCompleted);
     }
     this.InvokeAsync("RunAndFindMatches", new object[] {
                 profile,
                 dprofile}, this.RunAndFindMatchesOperationCompleted, userState);
 }
Пример #6
0
 /// <remarks/>
 public void RunAndFindMatchesAsync(Profile profile, DatingProfile dprofile) {
     this.RunAndFindMatchesAsync(profile, dprofile, null);
 }
Пример #7
0
 public List<MatchedResults> RunAndFindMatches(Profile profile, DatingProfile dprofile) {
     object[] results = this.Invoke("RunAndFindMatches", new object[] {
                 profile,
                 dprofile});
     return ((List<MatchedResults>)(results[0]));
 }
Пример #8
0
 /// <remarks/>
 public void DeletedatingProfileAsync(DatingProfile dprofile, object userState) {
     if ((this.DeletedatingProfileOperationCompleted == null)) {
         this.DeletedatingProfileOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeletedatingProfileOperationCompleted);
     }
     this.InvokeAsync("DeletedatingProfile", new object[] {
                 dprofile}, this.DeletedatingProfileOperationCompleted, userState);
 }
Пример #9
0
 /// <remarks/>
 public void DeletedatingProfileAsync(DatingProfile dprofile) {
     this.DeletedatingProfileAsync(dprofile, null);
 }
Пример #10
0
 /// <remarks/>
 public void LoadDatingProfileAsync(DatingProfile dprofile) {
     this.LoadDatingProfileAsync(dprofile, null);
 }
Пример #11
0
 /// <remarks/>
 public void UpdateDatingProfileAsync(DatingProfile dprofile) {
     this.UpdateDatingProfileAsync(dprofile, null);
 }
Пример #12
0
 public bool LoadDatingProfile(DatingProfile dprofile)
 {
     WorkerClass worker = new WorkerClass();
     return worker.LoadDatingProfile(dprofile);
 }
Пример #13
0
 public bool DeletedatingProfile(DatingProfile dprofile)
 {
     WorkerClass worker = new WorkerClass();
     return worker.DeletedateingProfile(dprofile);
 }
Пример #14
0
        public double matchPercentage(String user1, String user2)
        {
            db = new DataBaseWorker(connectionString);
            //get each users profile information
            Profile userOne = new Profile();
            userOne = loadProfileFromDB(user1, userOne);
            Profile userTwo = new Profile();
            userTwo = loadProfileFromDB(user2, userTwo);
            DatingProfile userOneWants = new DatingProfile();
            userOneWants = loadDatingProfileFromDB(user1, userOneWants);
            DatingProfile userTwoWants = new DatingProfile();
            userTwoWants = loadDatingProfileFromDB(user1, userTwoWants);

            //keep a running total of the total points
            double total_points = 0;

            //If height is in range add points (MAX 10)
            //check if userOne is in userTwos range
            if (userOne.Height_ft >= userTwoWants.Min_Height_ft && userOne.Height_ft <= userTwoWants.Max_Height_ft &&
                userOne.Height_in >= userTwoWants.Min_Height_in && userOne.Height_in <= userTwoWants.Min_Height_in)
            {
                total_points += 10;
            }
            //check if userTwo is in userOnes range

            if (userTwo.Height_ft >= userOneWants.Min_Height_ft && userTwo.Height_ft <= userOneWants.Max_Height_ft &&
                userTwo.Height_in >= userOneWants.Min_Height_in && userTwo.Height_in <= userOneWants.Min_Height_in)
            {
                total_points += 10;
            }

            //If weight is in range add points (MAX 10)
            //check if userOne is in userTwos range
            if (userOne.Weight >= userTwoWants.Min_Weight && userOne.Weight <= userTwoWants.Max_Weight)
            {
                total_points += 10;
            }
            //check if userTwo is in userOnes range
            if (userTwo.Weight >= userOneWants.Min_Weight && userTwo.Weight <= userOneWants.Max_Weight)
            {
                total_points += 10;
            }

            //If age is in range add points (MAX 10)
            //check if userOne is in userTwos range
            if (userOne.Age >= userTwoWants.Min_Age && userOne.Age <= userTwoWants.Max_Age)
            {
                total_points += 10;
            }
            //check if userTwo is in userOnes range
            if (userTwo.Age >= userOneWants.Min_Age && userTwo.Age <= userOneWants.Max_Age)
            {
                total_points += 10;
            }

            //10 points for race match
            if (userOne.Race == userTwoWants.Race)
            {
                total_points += 10;
            }
            if (userTwo.Race == userOneWants.Race)
            {
                total_points += 10;
            }

            //10 points for hair match
            if (userOne.Hair == userTwoWants.Hair)
            {
                total_points += 10;
            }
            if (userTwo.Hair == userOneWants.Hair)
            {
                total_points += 10;
            }

            //10 points for each matching interest
            if (userOne.Interest1 == userTwoWants.Interest1)
            {
                total_points += 10;
            }
            if (userTwo.Interest1 == userOneWants.Interest1)
            {
                total_points += 10;
            }
            //interest 2
            if (userOne.Interest2 == userTwoWants.Interest2)
            {
                total_points += 10;
            }
            if (userTwo.Interest2 == userOneWants.Interest2)
            {
                total_points += 10;
            }
            //interest 3
            if (userOne.Interest3 == userTwoWants.Interest3)
            {
                total_points += 10;
            }
            if (userTwo.Interest3 == userOneWants.Interest3)
            {
                total_points += 10;
            }

            return Math.Round((total_points / 160) * 100, 2);
        }
Пример #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dateProfile"></param>
 /// <returns></returns>
 public bool LoadDatingProfile(DatingProfile dateProfile)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat("INSERT INTO [noIdeas].[dbo].[datingAds] " +
       "([username],[sex],[min_age],[max_age],[race]" +
       ",[min_height_ft],[min_height_in],[max_height_ft],[max_height_in] " +
       ",[min_weight],[max_weight],[hair],[interest_1] ,[interest_2] " +
       ",[interest_3]) " +
       " VALUES('{0}', '{1}','{2}', '{3}','{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}','{12}','{13}','{14}')",
       dateProfile.NickName, dateProfile.Sex, dateProfile.Min_Age, dateProfile.Max_Age, dateProfile.Race,
       dateProfile.Min_Height_ft, dateProfile.Min_Height_in,dateProfile.Max_Height_ft, dateProfile.Max_Height_in,
       dateProfile.Min_Weight, dateProfile.Max_Weight,dateProfile.Hair,dateProfile.Interest1, dateProfile.Interest2, dateProfile.Interest3);
     int result = -1;
     try
     {
         db.OpenConnection();
         result = db.ExecuteSql(sql.ToString());
     }
     catch (Exception ex)
     {
     }
     finally
     {
         db.CloseConnection();
     }
     if (result == 1)
         return true;
     else
         return false;
 }