/// <summary> /// this method checks with the data base if there are friends who needs to be greeted. /// If there are it initiates the m_WorkList /// </summary> /// <returns></returns> private bool serviceNeedsToWork() { bool result = false; DataBaseHandler db = new DataBaseHandler(); m_GreetingJobs = db.GetFriendsOfApplicationUsersWithBirthdaysToday(); if (m_GreetingJobs.Count != 0) { result = true; } else { result = false; } return result; }
private void testyoav() { ApplicationUser me = FacebookUtilities.GetUser(m_AccessToken); Dictionary<string, Friend> friends = FacebookUtilities.GetUsersFriends(m_AccessToken); DataBaseHandler db = new DataBaseHandler(); db.InsertSingleApplicationUser(me); bool result = db.IsUserInDataBase(me); Dictionary<string, Friend> friendsThatAreInDB1 = db.GetUserFriendsThatAreInDataBase(me); Friend testfriend = new Friend(); foreach (Friend friend in friends.Values) { friend.BirthdayMessage = string.Format("mazal tov {0} from {1}", friend.FullName, me.FullName); testfriend = friend; } db.InsertFriendsIntoDataBase(me, friends.Values); Dictionary<string, Friend> friendsThatAreInDB2 = db.GetUserFriendsThatAreInDataBase(me); testfriend.BirthdayMessage = "CHANGED!!!!!!"; db.UpdateBirthdayMessage(me, testfriend); }
/// <summary> /// Executed when the finish button is clicked. /// This method should invoke a call to the database and add /// new messages to user's friend. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void finishButton_Click(object sender, EventArgs e) { m_DataBaseHandlerObject = new DataBaseHandler(); List<Friend> listOfFriendsToInsertMessage = new List<Friend>(); Friend currentFriend; // Adds all friends that have a message to be inserted, to the list // of friends. foreach (String stringiD in m_FriendsStringArray) { currentFriend = m_UserFriends[stringiD]; if (!string.IsNullOrEmpty(currentFriend.BirthdayMessage)) { listOfFriendsToInsertMessage.Add(currentFriend); } } // Insert friends with message to database m_DataBaseHandlerObject.InsertFriendsIntoDataBase(m_ApplicationUser, listOfFriendsToInsertMessage); // Returns to the welcomeStage Response.Redirect(string.Format("welcomeStage.aspx?access_token={0}", m_AccessToken)); }