예제 #1
0
        public static async Task <ValidateResult> ValidateWebAddress(NewWebsiteRequest state, object value)
        {
            var asString = value as string;
            var result   = new ValidateResult()
            {
                IsValid = false, Value = value
            };

            if (!string.IsNullOrEmpty(asString))
            {
                var extracted = CMSFormRequest.ExtractWebAddress(asString);
                if (string.IsNullOrEmpty(extracted))
                {
                    result.Value    = string.Empty;
                    result.Feedback = "That is not a valid web Address.  Please enter a valid URL.";
                }
                else
                {
                    result.Value   = extracted;
                    result.IsValid = true;
                }
            }

            return(result);
        }
예제 #2
0
        public static async Task <ValidateResult> ValidateDepartmentName(NewWebsiteRequest state, object value)
        {
            var comparisonString = value as string;
            var result           = new ValidateResult()
            {
                IsValid = true, Value = value
            };

            string         uri = "https://departments.documents.azure.com:443/";
            string         key = ConfigurationManager.AppSettings["DocumentDbKey"];
            DocumentClient client;

            SqlQuerySpec query = new SqlQuerySpec("SELECT d.longname FROM departments d WHERE d.url = @comparisonString OR d.longname = @comparisonString");

            query.Parameters = new SqlParameterCollection();
            query.Parameters.Add(new SqlParameter("@comparisonString", comparisonString.ToLower()));

            client = new DocumentClient(new Uri(uri), key);

            foreach (var dept in client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("departments", "departments"), query))
            {
                if (dept == null)
                {
                    result.Value = comparisonString;
                }
                else
                {
                    result.Value = dept.longname;
                    return(result);
                }
            }

            return(result);
        }
예제 #3
0
        private async Task NewWebsiteFormComplete(IDialogContext context, IAwaitable <NewWebsiteRequest> result)
        {
            NewWebsiteRequest siteRequest = null;

            try
            {
                siteRequest = await result;
            }
            catch (OperationCanceledException)
            {
                await context.PostAsync("You Cancelled the form!");

                return;
            }


            if (siteRequest.PermissionForYourself.ToString().ToLower() == "no")
            {
                var myform = new FormDialog <CMSFormRequest>(new CMSFormRequest(), CMSFormRequest.BuildForm, FormOptions.PromptInStart, null);
                context.Call <CMSFormRequest>(myform, CMSFormComplete);
                //await context.PostAsync("A request for New Website is successfuly raised. You will receive a confirmation email.");
                //await context.PostAsync("Is there anything else I can help you with?");
            }
        }