public AllAgreements(ref Dictionary <int, AddAgreement> p_all_add_agreements, CreateFormalMessageRequest p_send_formal_message_to_user, DB_IsThereUser p_is_there_user
                             , DB_AddToFriends p_add_to_friends, DB_AreFriends p_are_friends, DB_CreateAddAgreement p_create_add_agreement, DB_RemoveAgreement p_remove_agreement
                             , IsLoggedIn p_is_logged_in, StartClientFriendListChangedInformDialog p_start_client_friend_list_changed_inform_dialog, ReloadFriendList p_reload_friend_list
                             , GetOnlineUserFriendList p_get_online_user_friend_list, GetUserStatus p_get_user_status, AddAgreementDone p_add_agreement_done, GetAllAdAgreements p_get_all_agreements
                             , StartClientInvitedAgreementInform p_start_client_invited_agreement_inform)
        {
            send_formal_message_to_user = p_send_formal_message_to_user;
            is_there_user        = p_is_there_user;
            add_to_friends       = p_add_to_friends;
            are_friends          = p_are_friends;
            create_add_agreement = p_create_add_agreement;
            remove_agreement     = p_remove_agreement;
            is_logged_in         = p_is_logged_in;
            start_client_friend_list_changed_inform_dialog = p_start_client_friend_list_changed_inform_dialog;
            reload_friend_list                    = p_reload_friend_list;
            get_online_user_friend_list           = p_get_online_user_friend_list;
            get_user_status                       = p_get_user_status;
            add_agreement_done                    = p_add_agreement_done;
            get_all_agreements                    = p_get_all_agreements;
            start_client_invited_agreement_inform = p_start_client_invited_agreement_inform;

            ma_add_agreement_manager = new Ma_AddAgreementManager(ref p_all_add_agreements, new CreateFormalMessageRequest(AllAg_SendFormlMessageToUser)
                                                                  , new DB_IsThereUser(AllAg_IsThereUser), new DB_AddToFriends(AllAg_AddToFriends), new DB_AreFriends(AllAg_AreFriends)
                                                                  , new DB_CreateAddAgreement(AllAg_CreateAddAgreement), new DB_RemoveAgreement(AllAg_RemoveAgreement), new IsLoggedIn(AllAg_IsLoggedIn)
                                                                  , new StartClientFriendListChangedInformDialog(AllAg_StartClientFriendListChangedInformDialog), new ReloadFriendList(AllAg_ReloadFriendList)
                                                                  , new GetOnlineUserFriendList(AllAg_GetOnlineUserFriendList), new GetUserStatus(AllAg_GetUserStatus), add_agreement_done
                                                                  , new GetAllAdAgreements(AllAg_GetAllAdAgreements), new StartClientInvitedAgreementInform(AllAg_StartClientInvitedAgreementInform));
        }
 public void BaseConstruct(TypeOfAgreement p_agreement_type, int p_max_invited_persons, CreateFormalMessageRequest p_send_formal_message_to_user
                           , DB_IsThereUser p_is_there_user, StartClientInvitedAgreementInform p_start_client_invited_agreement_inform, IsLoggedIn p_is_logged_in)
 {
     agreement_type = p_agreement_type;
     send_formal_message_to_user           = p_send_formal_message_to_user;
     start_client_invited_agreement_inform = p_start_client_invited_agreement_inform;
     is_logged_in        = p_is_logged_in;
     is_there_user       = p_is_there_user;
     max_invited_persons = p_max_invited_persons;
 }
        protected void BaseConstruct(TypeOfAgreement p_agreement_type, int p_agreement_id, string p_starter_user_name
                                     , int p_max_invited_persons, RemoveAgr p_remove_agreement_from_manager, CreateFormalMessageRequest p_send_formal_message_to_user
                                     , DB_IsThereUser p_is_there_user, Dictionary <string, bool> p_all_users_invited, IsLoggedIn p_is_logged_in)
        {
            all_users_invited = p_all_users_invited;

            agreement_id        = p_agreement_id;
            max_invited_persons = p_max_invited_persons;
            agreement_type      = p_agreement_type;
            starter_user_name   = p_starter_user_name;

            remove_agreement_from_manager = p_remove_agreement_from_manager;
            send_formal_message_to_user   = p_send_formal_message_to_user;
            is_there_user = p_is_there_user;
            is_logged_in  = p_is_logged_in;
        }
        public AddAgreement(int p_agreement_id, string p_starter_user_name, string p_invited_person_user_name, RemoveAgr p_remove_agreement_from_manager
                            , DB_AddToFriends p_add_to_friends, DB_AreFriends p_are_friends, DB_CreateAddAgreement p_create_add_agreement
                            , DB_RemoveAgreement p_remove_agreement, CreateFormalMessageRequest p_send_formal_message_to_user, DB_IsThereUser p_is_there_user
                            , GetUserStatus p_get_user_status, IsLoggedIn p_is_logged_in, StartClientFriendListChangedInformDialog p_start_client_friend_list_changed_inform_dialog
                            , ReloadFriendList p_reload_friend_list, GetOnlineUserFriendList p_get_online_user_friend_list, AddAgreementDone p_add_agreement_done)
        {
            Dictionary <string, bool> t_all_users_invited = new Dictionary <string, bool>();

            t_all_users_invited.Add(p_invited_person_user_name, false);

            base.BaseConstruct(TypeOfAgreement.Add, p_agreement_id, p_starter_user_name, 1, p_remove_agreement_from_manager, p_send_formal_message_to_user, p_is_there_user
                               , t_all_users_invited, p_is_logged_in);

            add_to_friends       = p_add_to_friends;
            are_friends          = p_are_friends;
            create_add_agreement = p_create_add_agreement;
            remove_agreement     = p_remove_agreement;
            get_user_status      = p_get_user_status;
            start_client_friend_list_changed_inform_dialog = p_start_client_friend_list_changed_inform_dialog;
            reload_friend_list          = p_reload_friend_list;
            get_online_user_friend_list = p_get_online_user_friend_list;
            get_user_status             = p_get_user_status;
            add_agreement_done          = p_add_agreement_done;
        }
        public Ma_AddAgreementManager(ref Dictionary <int, AddAgreement> p_all_agreements, CreateFormalMessageRequest p_send_formal_messages_to_user
                                      , DB_IsThereUser p_is_there_user, DB_AddToFriends p_add_to_friends, DB_AreFriends p_are_friends, DB_CreateAddAgreement p_create_add_agreement
                                      , DB_RemoveAgreement p_remove_agreement, IsLoggedIn p_is_logged_in, StartClientFriendListChangedInformDialog p_start_client_friend_list_changed_inform_dialog
                                      , ReloadFriendList p_reload_friend_list, GetOnlineUserFriendList p_get_online_user_friend_list, GetUserStatus p_get_user_status, AddAgreementDone p_add_agreement_done
                                      , GetAllAdAgreements p_get_all_agreements, StartClientInvitedAgreementInform p_start_client_invited_agreement_inform)
        {
            base.BaseConstruct(TypeOfAgreement.Add, 1, p_send_formal_messages_to_user, p_is_there_user, p_start_client_invited_agreement_inform, p_is_logged_in);

            add_to_friends       = p_add_to_friends;
            are_friends          = p_are_friends;
            create_add_agreement = p_create_add_agreement;
            remove_agreement     = p_remove_agreement;
            start_client_friend_list_changed_inform_dialog = p_start_client_friend_list_changed_inform_dialog;
            reload_friend_list          = p_reload_friend_list;
            get_online_user_friend_list = p_get_online_user_friend_list;
            get_user_status             = p_get_user_status;
            add_agreement_done          = p_add_agreement_done;
            get_all_agreements          = p_get_all_agreements;

            all_agreements = p_all_agreements;

            List <Agreement> all_db_agreements = new List <Agreement>();
            int h = 0;

            while (h < 4)
            {
                try
                {
                    all_db_agreements = get_all_agreements();
                    h = 0;
                    break;
                }
                catch
                {
                    h++;
                    continue;
                }
            }
            if (h > 3)
            {
                Console.WriteLine("could not get all agreements from DB");
                try
                {
                    Environment.Exit(4);
                }
                catch
                {
                }
                Thread.CurrentThread.Abort();
            }
            foreach (Agreement t_agreement in all_db_agreements)
            {
                AddAgreement temp_add_agreement = new AddAgreement(t_agreement.Get_agreement_id, t_agreement.Get_inviting_user_name, t_agreement.Get_invited_user_name, new RemoveAgr(AgreementRemoveItselfRequest)
                                                                   , new DB_AddToFriends(add_to_friends), new DB_AreFriends(are_friends), new DB_CreateAddAgreement(create_add_agreement), new DB_RemoveAgreement(remove_agreement)
                                                                   , new CreateFormalMessageRequest(Ma_SendFormalMessageToUser), new DB_IsThereUser(is_there_user), new GetUserStatus(Ma_GetUserStatus), new IsLoggedIn(Ma_IsLoggedIn), new StartClientFriendListChangedInformDialog(Ma_StartClientFriendListChangedInformDialog)
                                                                   , new ReloadFriendList(Ma_ReloadFriendList), new GetOnlineUserFriendList(Ma_GetOnlineUserFriendList), new AddAgreementDone(add_agreement_done));
                all_agreements.Add(t_agreement.Get_agreement_id, temp_add_agreement);
            }
        }