Exemplo n.º 1
0
        /// <summary>
        /// Builds a prayer request from data in the UI Fields and kicks off the post UI Control
        /// </summary>
        void SubmitPrayerRequest(object sender, EventArgs e)
        {
            if (PickerAdjustManager.Revealed == true)
            {
                OnToggleCategoryPicker(false);
            }
            else
            {
                // if first and last name are valid, OR anonymous is on
                // and if there's text in the request field.
                if (CheckDebug( ) == false)
                {
                    if (ValidateInput( ))
                    {
                        Rock.Client.PrayerRequest prayerRequest = new Rock.Client.PrayerRequest();

                        EnableControls(false);

                        prayerRequest.FirstName = FirstName.Field.Text;
                        prayerRequest.LastName  = LastName.Field.Text;
                        prayerRequest.Email     = Email.Field.Text;

                        // see if there's a person alias ID to use.
                        int?personAliasId = null;
                        if (MobileApp.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId.HasValue)
                        {
                            personAliasId = MobileApp.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId;
                        }

                        prayerRequest.Text                   = PrayerRequest.Text;
                        prayerRequest.EnteredDateTime        = DateTime.Now;
                        prayerRequest.ExpirationDate         = DateTime.Now.Add(PrivatePrayerConfig.PrayerExpirationTime);
                        prayerRequest.CategoryId             = RockLaunchData.Instance.Data.PrayerCategoryToId(CategoryButton.Title(UIControlState.Normal));
                        prayerRequest.IsActive               = true;
                        prayerRequest.IsPublic               = UIPublicSwitch.On; // use the public switch's state to determine whether it's a public prayer or not.
                        prayerRequest.Guid                   = Guid.NewGuid( );
                        prayerRequest.IsApproved             = false;
                        prayerRequest.CreatedByPersonAliasId = /*UISwitchAnonymous.On == true ? null :*/ personAliasId;

                        // launch the post view controller
                        Prayer_PostUIViewController postPrayerVC = new Prayer_PostUIViewController();
                        postPrayerVC.PrayerRequest = prayerRequest;
                        Task.PerformSegue(this, postPrayerVC);
                    }
                }
            }
        }
        /// <summary>
        /// Builds a prayer request from data in the UI Fields and kicks off the post UI Control
        /// </summary>
        void SubmitPrayerRequest(object sender, EventArgs e)
        {
            if ( PickerAdjustManager.Revealed == true )
            {
                OnToggleCategoryPicker( false );
            }
            else
            {
                // if first and last name are valid, OR anonymous is on
                // and if there's text in the request field.
                if ( CheckDebug( ) == false )
                {
                    if ( ValidateInput( ) )
                    {
                        Rock.Client.PrayerRequest prayerRequest = new Rock.Client.PrayerRequest();

                        EnableControls( false );

                        prayerRequest.FirstName = FirstName.Field.Text;
                        prayerRequest.LastName = LastName.Field.Text;

                        // see if there's a person alias ID to use.
                        int? personAliasId = null;
                        if ( App.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId.HasValue )
                        {
                            personAliasId = App.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId;
                        }

                        prayerRequest.Text = PrayerRequest.Text;
                        prayerRequest.EnteredDateTime = DateTime.Now;
                        prayerRequest.ExpirationDate = DateTime.Now.Add( PrivatePrayerConfig.PrayerExpirationTime );
                        prayerRequest.CategoryId = RockGeneralData.Instance.Data.PrayerCategoryToId( CategoryButton.Title( UIControlState.Normal ) );
                        prayerRequest.IsActive = true;
                        prayerRequest.IsPublic = UIPublicSwitch.On; // use the public switch's state to determine whether it's a public prayer or not.
                        prayerRequest.Guid = Guid.NewGuid( );
                        prayerRequest.IsApproved = false;
                        prayerRequest.CreatedByPersonAliasId = UISwitchAnonymous.On == true ? null : personAliasId;

                        // launch the post view controller
                        Prayer_PostUIViewController postPrayerVC = new Prayer_PostUIViewController();
                        postPrayerVC.PrayerRequest = prayerRequest;
                        Task.PerformSegue( this, postPrayerVC );
                    }
                }
            }
        }