public LegalTreatyCard(string treatyName, List <TextEntity> legal)
        {
            Version = new AdaptiveSchemaVersion(1, 0);
            Body.Add(new AdaptiveTextBlock(treatyName)
            {
                Color     = AdaptiveTextColor.Accent,
                Height    = new AdaptiveHeight(24),
                Separator = true
            });

            foreach (var procedure in legal)
            {
                if (procedure.Type == "link")
                {
                    Body.Add(new AdaptiveMedia()
                    {
                        AltText = "Link",
                        Sources = new List <AdaptiveMediaSource>()
                        {
                            new AdaptiveMediaSource("url", procedure.Value)
                        }
                    });
                }
                Body.Add(new AdaptiveTextBlock(procedure.Value)
                {
                    Wrap      = true,
                    Color     = procedure.Type == "title" ? AdaptiveTextColor.Accent : AdaptiveTextColor.Default,
                    Separator = procedure.Type == "title"
                });
            }
        }
Exemple #2
0
        public PersonAdaptiveCard(Person person, string fieldToAccent = "") : base()
        {
            Version = new AdaptiveSchemaVersion(1, 0);
            Body.Add(new AdaptiveTextBlock($"{person.FullName}")
            {
                Weight   = AdaptiveTextWeight.Bolder,
                IsSubtle = false
            });

            if (!string.IsNullOrEmpty(person.Image))
            {
                Body.Add(new AdaptiveImage(person.Image)
                {
                    PixelWidth  = 32,
                    PixelHeight = 32
                });
            }

            TryAddField(
                "Cumpleaños: {0}",
                person.BirthDate.ToString("dd-MM-yyyy"),
                fieldToAccent.NormalizeString() == "birthdate");

            TryAddField("Area: {0}", person.Area, fieldToAccent.NormalizeString() == "area");
            TryAddField("Interno: {0}", person.Intern, fieldToAccent.NormalizeString() == "intern");
            TryAddField("Móvil: {0}", person.Mobile, fieldToAccent.NormalizeString() == "mobile");
            TryAddField("Telefono: {0}", person.Phone, fieldToAccent.NormalizeString() == "phone");
            TryAddField("Email: {0}", person.Email, fieldToAccent.NormalizeString() == "email");
            TryAddField("Direccion {0}", person.Address, fieldToAccent.NormalizeString() == "address");
        }
        public void OperatorTests()
        {
            var v10 = new AdaptiveSchemaVersion(1, 0);
            var v11 = new AdaptiveSchemaVersion(1, 1);

            Assert.IsFalse(v10 == v11);
            Assert.IsFalse(v10.Equals(v11));
            Assert.IsTrue(v11 > v10);
            Assert.IsTrue(v10 < v11);
            Assert.IsTrue(v11 >= v10);
        }
        public void Setup()
        {
            _activity = new Activity()
            {
                Speak = parentSpeakProperty
            };
            _promptOptions = new PromptOptions()
            {
                Prompt = new Activity()
                {
                    Text = parentSpeakProperty, Speak = parentSpeakProperty
                }
            };

            adaptiveSchemaVersion = new AdaptiveSchemaVersion(1, 2);
        }
        public EmergencyProcedureCard(string procedureName, List <string> procedures)
        {
            Version = new AdaptiveSchemaVersion(1, 0);
            Body.Add(new AdaptiveTextBlock(procedureName)
            {
                Color     = AdaptiveTextColor.Accent,
                Height    = new AdaptiveHeight(24),
                Separator = true
            });

            foreach (var procedure in procedures)
            {
                Body.Add(new AdaptiveTextBlock(procedure)
                {
                    Wrap      = true,
                    Color     = AdaptiveTextColor.Default,
                    Separator = true
                });
            }
        }
Exemple #6
0
        public async Task <IActionResult> Register([FromBody] RegistrationBindingModel registrationBindingModel)
        {
            HtmlTag htmlTag = new HtmlTag("", true);

            if (string.IsNullOrWhiteSpace(registrationBindingModel.EmailAddress))
            {
                return(BadRequest(new GenericViewModel
                {
                    Message = "Email Address needs to supplied."
                }));
            }
            if (string.IsNullOrWhiteSpace(registrationBindingModel.PhoneNumber))
            {
                return(BadRequest(new GenericViewModel
                {
                    Message = "Phone Number needs to supplied."
                }));
            }
            var attendee = await _context.Attendees.FirstOrDefaultAsync(x => x.EmailAddress == registrationBindingModel.EmailAddress);

            if (attendee != null)
            {
                var response = StatusCode((int)HttpStatusCode.Conflict, new GenericViewModel
                {
                    Message = "Sorry, a user with that email address has been registered."
                });
                return(response);
            }
            attendee = new Models.Data.Attendee
            {
                FirstName        = registrationBindingModel.FirstName,
                LastName         = registrationBindingModel.LastName,
                EmailAddress     = registrationBindingModel.EmailAddress,
                RegistrationDate = DateTime.Now
            };
            // Create a card renderer
            AdaptiveCardRenderer renderer = new AdaptiveCardRenderer();
            // For fun, check the schema version this renderer supports
            AdaptiveSchemaVersion schemaVersion = renderer.SupportedSchemaVersion; // 1.0

            // Build a simple card
            // In the real world this would probably be provided as JSON
            AdaptiveCard card = new AdaptiveCard()
            {
                Body = new List <AdaptiveElement>()
                {
                    new AdaptiveContainer()
                    {
                    },
                    new AdaptiveContainer()
                    {
                    }
                },
                Actions = new List <AdaptiveAction>()
                {
                    new AdaptiveOpenUrlAction()
                    {
                    },
                    new AdaptiveOpenUrlAction()
                    {
                    }
                }
            };

            try
            {
                // Render the card
                RenderedAdaptiveCard renderedCard = renderer.RenderCard(card);

                // Get the output HTML
                htmlTag = renderedCard.Html;

                // (Optional) Check for any renderer warnings
                // This includes things like an unknown element type found in the card
                // Or the card exceeded the maxmimum number of supported actions, etc
                IList <AdaptiveWarning> warnings = renderedCard.Warnings;
            }
            catch (AdaptiveException ex)
            {
                // Failed rendering
            }

            var _Attendee = _context.Attendees.Add(attendee);
            await _context.SaveChangesAsync();

            await Services.EmailService.SendRegistrationEmail(attendee, htmlTag);

            return(Created($"http://events.windforcecorp.com/{_Attendee.Entity.AttendeeID.ToString()}", _Attendee));
        }
        /// <summary>
        /// Create an adaptive card instance.
        /// </summary>
        /// <param name="title">The adaptive card's title value.</param>
        /// <param name="imageUrl">The adaptive card's image URL.</param>
        /// <param name="summary">The adaptive card's summary value.</param>
        /// <param name="author">The adaptive card's author value.</param>
        /// <param name="buttonTitle">The adaptive card's button title value.</param>
        /// <param name="buttonUrl">The adaptive card's button url value.</param>
        /// <returns>The created adaptive card instance.</returns>
        public AdaptiveCard CreateAdaptiveCard(
            string title,
            string imageUrl,
            string summary,
            string author,
            string buttonTitle,
            string buttonUrl,
            string rowkey)
        {
            var          version = new AdaptiveSchemaVersion(1, 0);
            AdaptiveCard card    = new AdaptiveCard(version);

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text   = title,
                Size   = AdaptiveTextSize.ExtraLarge,
                Weight = AdaptiveTextWeight.Bolder,
                Wrap   = true,
            });

            if (!string.IsNullOrWhiteSpace(imageUrl))
            {
                card.Body.Add(new AdaptiveImage()
                {
                    Url     = new Uri(imageUrl, UriKind.RelativeOrAbsolute),
                    Spacing = AdaptiveSpacing.Default,
                    Size    = AdaptiveImageSize.Stretch,
                    AltText = string.Empty,
                });
            }

            if (!string.IsNullOrWhiteSpace(summary))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text = summary,
                    Wrap = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(author))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = author,
                    Size   = AdaptiveTextSize.Small,
                    Weight = AdaptiveTextWeight.Lighter,
                    Wrap   = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(buttonTitle) &&
                !string.IsNullOrWhiteSpace(buttonUrl))
            {
                card.Actions.Add(new AdaptiveOpenUrlAction()
                {
                    Title = buttonTitle,
                    Url   = new Uri(this.hostName + "/redirect?" + this.urlparam + buttonUrl + "&" + this.rowkeyparam + rowkey, UriKind.RelativeOrAbsolute),
                });
            }

            return(card);
        }
Exemple #8
0
        /// <summary>
        /// Create an adaptive card instance.
        /// </summary>
        /// <param name="title">The adaptive card's title value.</param>
        /// <param name="imageUrl">The adaptive card's image URL.</param>
        /// <param name="summary">The adaptive card's summary value.</param>
        /// <param name="author">The adaptive card's author value.</param>
        /// <param name="buttonTitle">The adaptive card's button title value.</param>
        /// <param name="buttonUrl">The adaptive card's button url value.</param>
        /// <param name="buttons">The adaptive card's collection of buttons.</param>
        /// <param name="trackingurl">The adaptive card read tracking url.</param>
        /// <param name="cardimage">Image for the card when targeting is enabled.</param>
        /// <param name="cardtitle">Title for the card when targeting is enabled.</param>
        /// <returns>The created adaptive card instance.</returns>
        public AdaptiveCard CreateAdaptiveCard(
            string title,
            string imageUrl,
            string summary,
            string author,
            string buttonTitle,
            string buttonUrl,
            string buttons,
            string trackingurl,
            string cardimage,
            string cardtitle)
        {
            var          version = new AdaptiveSchemaVersion(1, 0);
            AdaptiveCard card    = new AdaptiveCard(version);

            if (!string.IsNullOrWhiteSpace(cardimage))
            {
                card.Body.Add(new AdaptiveImage()
                {
                    Url = new Uri(cardimage, UriKind.RelativeOrAbsolute),
                });
            }

            if (!string.IsNullOrWhiteSpace(cardtitle))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text = cardtitle,
                    Wrap = true,
                });
            }

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text      = title,
                Size      = AdaptiveTextSize.ExtraLarge,
                Weight    = AdaptiveTextWeight.Bolder,
                Wrap      = true,
                Separator = true,
            });

            if (!string.IsNullOrWhiteSpace(imageUrl))
            {
                card.Body.Add(new AdaptiveImage()
                {
                    Url     = new Uri(imageUrl, UriKind.RelativeOrAbsolute),
                    Spacing = AdaptiveSpacing.Default,
                    Size    = AdaptiveImageSize.Stretch,
                    AltText = string.Empty,
                });
            }

            if (!string.IsNullOrWhiteSpace(summary))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text = summary,
                    Wrap = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(author))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = author,
                    Size   = AdaptiveTextSize.Small,
                    Weight = AdaptiveTextWeight.Lighter,
                    Wrap   = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(buttonTitle) &&
                !string.IsNullOrWhiteSpace(buttonUrl) &&
                string.IsNullOrWhiteSpace(buttons))
            {
                card.Actions.Add(new AdaptiveOpenUrlAction()
                {
                    Title = buttonTitle,
                    Url   = new Uri(buttonUrl, UriKind.RelativeOrAbsolute),
                });
            }

            if (!string.IsNullOrWhiteSpace(buttons))
            {
                // enables case insensitive deserialization for card buttons
                var options = new JsonSerializerOptions
                {
                    PropertyNameCaseInsensitive = true,
                };

                // add the buttons string to the buttons collection for the card
                card.Actions.AddRange(JsonSerializer.Deserialize <List <AdaptiveOpenUrlAction> >(buttons, options));
            }

            if (!string.IsNullOrWhiteSpace(trackingurl))
            {
                string trul = trackingurl + "/?id=[ID]&key=[KEY]";

                card.Body.Add(new AdaptiveImage()
                {
                    Url       = new Uri(trul, UriKind.RelativeOrAbsolute),
                    Spacing   = AdaptiveSpacing.Small,
                    Size      = AdaptiveImageSize.Small,
                    IsVisible = false,
                    AltText   = string.Empty,
                });
            }

            return(card);
        }
        /// <summary>
        /// Create an adaptive card instance.
        /// </summary>
        /// <param name="title">The adaptive card's title value.</param>
        /// <param name="imageUrl">The adaptive card's image URL.</param>
        /// <param name="summary">The adaptive card's summary value.</param>
        /// <param name="author">The adaptive card's author value.</param>
        /// <param name="buttonTitle">The adaptive card's button title value.</param>
        /// <param name="buttonUrl">The adaptive card's button URL value.</param>
        /// <param name="buttonTitle2">The adaptive card's second button title value.</param>
        /// <param name="buttonUrl2">The adaptive card's second button URL value.</param>
        /// <param name="notificationid">The notification id.</param>
        /// <param name="isAcknowledgementRequired">Indicates whether acknowledge button is required or not.</param>
        /// <returns>The created adaptive card instance.</returns>
        public AdaptiveCard CreateAdaptiveCard(
            string title,
            string imageUrl,
            string summary,
            string author,
            string buttonTitle,
            string buttonUrl,
            string buttonTitle2,
            string buttonUrl2,
            string notificationid,
            bool isAcknowledgementRequired = true)
        {
            var          version = new AdaptiveSchemaVersion(1, 0);
            AdaptiveCard card    = new AdaptiveCard(version);

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text   = title,
                Size   = AdaptiveTextSize.ExtraLarge,
                Weight = AdaptiveTextWeight.Bolder,
                Wrap   = true,
            });

            if (!string.IsNullOrWhiteSpace(imageUrl) && imageUrl != "https://")
            {
                card.Body.Add(new AdaptiveImage()
                {
                    Url     = new Uri(imageUrl, UriKind.RelativeOrAbsolute),
                    Spacing = AdaptiveSpacing.Default,
                    Size    = AdaptiveImageSize.Stretch,
                    AltText = string.Empty,
                });
            }

            if (!string.IsNullOrWhiteSpace(summary))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text = summary,
                    Wrap = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(author))
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = author,
                    Size   = AdaptiveTextSize.Small,
                    Weight = AdaptiveTextWeight.Lighter,
                    Wrap   = true,
                });
            }

            if (!string.IsNullOrWhiteSpace(buttonTitle) &&
                !string.IsNullOrWhiteSpace(buttonUrl) && buttonUrl != "https://")
            {
                card.Actions.Add(new AdaptiveOpenUrlAction()
                {
                    Title = buttonTitle,
                    Url   = new Uri(buttonUrl, UriKind.RelativeOrAbsolute),
                });
            }

            if (!string.IsNullOrWhiteSpace(buttonTitle2) &&
                !string.IsNullOrWhiteSpace(buttonUrl2) && buttonUrl2 != "https://")
            {
                card.Actions.Add(new AdaptiveOpenUrlAction()
                {
                    Title = buttonTitle2,
                    Url   = new Uri(buttonUrl2, UriKind.RelativeOrAbsolute),
                });
            }

            // Acknowledgment button.
            if (isAcknowledgementRequired)
            {
                card.Actions.Add(new AdaptiveSubmitAction
                {
                    Title = Acknowledgment,
                    Data  = new MessageCard {
                        Title = title, ImageUrl = imageUrl, Summary = summary, Author = author, ButtonTitle = buttonTitle, ButtonUrl = buttonUrl, ButtonTitle2 = buttonTitle2, ButtonUrl2 = buttonUrl2, NotificationId = notificationid
                    },
                });
            }

            return(card);
        }