Example #1
0
        /// <summary>
        /// Builds the common fields.
        /// </summary>
        /// <param name="request">The prayer request.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>A string containing the XAML that represents the common Group fields.</returns>
        private string BuildCommonFields(PrayerRequest request, Dictionary <string, string> parameters)
        {
            var    sb = new StringBuilder();
            string field;

            string firstName = request != null ? request.FirstName : RequestContext.CurrentPerson?.FirstName;
            string lastName  = request != null ? request.LastName : RequestContext.CurrentPerson?.LastName;
            string email     = request != null ? request.Email : RequestContext.CurrentPerson?.Email;

            field = MobileHelper.GetTextEditFieldXaml("firstName", "First Name", firstName, true);
            sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
            parameters.Add("firstName", "Text");

            field = MobileHelper.GetTextEditFieldXaml("lastName", "Last Name", lastName, RequireLastName);
            sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
            parameters.Add("lastName", "Text");

            field = MobileHelper.GetEmailEditFieldXaml("email", "Email", email, false);
            sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
            parameters.Add("email", "Text");

            if (ShowCampus && CampusCache.All().Where(a => a.IsActive ?? false).Count() > 1)
            {
                field = $"<Rock:CampusPicker x:Name=\"campus\" Label=\"Campus\" IsRequired=\"{RequireCampus}\" SelectedValue=\"{request?.Campus?.Guid.ToStringSafe()}\" />";
                sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
                parameters.Add("campus", "SelectedValue");
            }

            if (ShowCategory && ParentCategory.HasValue)
            {
                var items = CategoryCache.Get(ParentCategory.Value)
                            .Categories
                            .Select(a => new KeyValuePair <string, string>(a.Guid.ToString(), a.Name));

                var categoryGuid = request?.Category?.Guid;
                if (!categoryGuid.HasValue && DefaultCategory.HasValue)
                {
                    categoryGuid = CategoryCache.Get(DefaultCategory.Value).Guid;
                }

                field = MobileHelper.GetDropDownFieldXaml("category", "Category", categoryGuid.ToStringSafe(), true, items);
                sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
                parameters.Add("category", "SelectedValue");
            }

            field = MobileHelper.GetTextEditFieldXaml("request", "Request", request?.Text, true, true, CharacterLimit);
            sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
            parameters.Add("request", "Text");

            if (ShowPublicDisplayFlag)
            {
                field = MobileHelper.GetCheckBoxFieldXaml("allowPublication", "Allow Publication", request?.IsPublic ?? DefaultToPublic);
                sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
                parameters.Add("allowPublication", "IsChecked");
            }

            if (ShowUrgentFlag)
            {
                field = MobileHelper.GetCheckBoxFieldXaml("urgent", "Urgent", request?.IsUrgent ?? false);
                sb.AppendLine(MobileHelper.GetSingleFieldXaml(field));
                parameters.Add("urgent", "IsChecked");
            }

            return(sb.ToString());
        }