private static ListTemplate1 CreateListTemplate1(SkillTypen typ, List <ListItem> listItems, string title)
        {
            var url = skillParameter.FirstOrDefault(v => v.Typ == typ)?.UrlTemplate;

            if (listItems.Count == 0 || listItems == null)
            {
                var item = CreateNoContentList();
                listItems.Add(item);
            }

            return(new ListTemplate1
            {
                Token = typ.ToString(),
                Title = title,
                BackButton = BackButtonVisibility.Visible,
                BackgroundImage = new TemplateImage
                {
                    ContentDescription = "_Icon",
                    Sources = new List <ImageSource> {
                        new ImageSource {
                            Url = url
                        }
                    }
                },
                Items = listItems
            });
        }
        public static SkillResponse GibEinfacheAntwort(SkillRequest request, SkillTypen typ, string text, string title, string speech, DateTime date, bool?shouldEndSession)
        {
            if (speech == null)
            {
                speech = text;
            }

            var response = new SkillResponse
            {
                Version           = "1.0",
                SessionAttributes = CreateSessionAttributes(request, typ, -1, null, date),
                Response          = new ResponseBody
                {
                    Card = new SimpleCard
                    {
                        Title   = title,
                        Content = text
                    },
                    Reprompt     = CreateReprompt(),
                    OutputSpeech = new SsmlOutputSpeech {
                        Ssml = $"<speak>{speech}</speak>"
                    },
                    ShouldEndSession = shouldEndSession
                                       //ShouldEndSession = shouldEndSession,
                }
            };

            return(response);
        }
        private static ICard CreateCard(SkillTypen typ, List <SpeisePlan> items, DateTime tag)
        {
            var url     = skillParameter.FirstOrDefault(t => t.Typ == typ)?.UrlCard;
            var title   = $"{skillParameter.FirstOrDefault(t => t.Typ == typ)?.CardTitle} {tag.ToShortDateString()}";
            var content = "";

            if (items.Count > 0)
            {
                var i = 1;
                foreach (var item in items)
                {
                    content += $"{i}. {item.Beschreibung} für {item.Preis} €\n";
                    i++;
                }
            }
            else
            {
                content += FehlerTypen.NoSpeisePlan.ToDescription();
            }

            var cardImage = new CardImage
            {
                SmallImageUrl = url,
                LargeImageUrl = url
            };

            return(new StandardCard
            {
                Content = content,
                Title = title,
                Image = cardImage
            });
        }
        private static IOutputSpeech CreateSpeech(SkillTypen typ, List <SpeisePlan> items, DateTime tag, bool today)
        {
            var text = "";

            if (items.Count > 0)
            {
                if (today)
                {
                    text += $"{typ.ToDescription()}. ";
                }
                else
                {
                    text += $"{typ.ToDescription()} {ToWochentag(tag)} den {tag.SayAsDateYear()}. ";
                }

                text += CreateEssensPlanSpeech(items);
            }
            else
            {
                text += FehlerTypen.NoSpeisePlan.ToDescription();
            }

            return(new SsmlOutputSpeech {
                Ssml = $"<speak>{text}</speak>"
            });
        }
        private static string CreateTitle(SkillTypen typ, int kategorie, double preis, int kw)
        {
            var menue = ((MenueKategorien)kategorie).ToDescription();
            var text  = $"{skillParameter.FirstOrDefault(t => t.Typ == typ)?.CardTitle} {kw}";

            return($"{menue} {text} ({preis.ToString("F2")} €)");
        }
 public static SkillResponse CreateBodySkillResponse(SkillRequest request, SkillTypen typ, BodyTemplate2 template, IOutputSpeech speech, ICard card, DateTime date, bool?shouldEndSession)
 {
     return(new SkillResponse
     {
         Version = "1.0",
         Response = CreateBodyResponseBody(request, template, speech, card, shouldEndSession),
         SessionAttributes = CreateSessionAttributes(request, typ, -1, null, date)
     });
 }
 public static SkillResponse CreateListSkillResponse(SkillRequest request, SkillTypen typ, List <ListItem> listItems, IOutputSpeech speech, ICard card, string title, DateTime date, bool?shouldEndSession)
 {
     return(new SkillResponse
     {
         Version = "1.0",
         Response = CreateListResponseBody(request, typ, listItems, speech, card, title, shouldEndSession),
         SessionAttributes = CreateSessionAttributes(request, typ, -1, listItems, date)
     });
 }
        private static IList <IDirective> CreateListDirectives(SkillTypen typ, List <ListItem> listItems, string title)
        {
            var directive = new DisplayRenderTemplateDirective();

            directive.Template = CreateListTemplate1(typ, listItems, title);
            var items = new List <IDirective>();

            items.Add(directive);

            return(items);
        }
        private static BodyTemplate2 CreateTemplate(SkillTypen typ, SkillBodyContent content, int kategorie, DateTime tag)
        {
            var title = ((MenueKategorien)kategorie).ToDescription();

            if (tag != null)
            {
                title += $" für {tag.Date.ToShortDateString()}";
            }

            return(AddBodyContent(typ, content, title));
        }
        private static string CreateTitle(SkillTypen typ, DateTime tag, bool today)
        {
            var title = skillParameter.FirstOrDefault(t => t.Typ == typ)?.CardTitle;

            if (!today)
            {
                title += $" {ToWochentag(tag)} den {tag.ToShortDateString()}";
            }

            return(title);
        }
        private static ResponseBody CreateListResponseBody(SkillRequest request, SkillTypen typ, List <ListItem> listItems, IOutputSpeech speech, ICard card, string title, bool?shouldEndSession)
        {
            var hasDisplay = request.HasDisplay();
            var body       = new ResponseBody
            {
                OutputSpeech     = speech,
                Card             = card,
                Reprompt         = CreateReprompt(),
                ShouldEndSession = shouldEndSession
            };

            if (hasDisplay)
            {
                body.Directives = CreateListDirectives(typ, listItems, title);
            }

            return(body);
        }
        private static IOutputSpeech CreateSpeech(SkillTypen typ, List <SpeisePlan> items, int kategorie, int kw)
        {
            var text = "";

            if (items.Count > 0)
            {
                var i            = 0;
                var missingDates = GetMissingDays(items);
                var menue        = ((MenueKategorien)kategorie).ToDescription();
                text += $"{typ.ToDescription()} {kw} für {menue} eingeplant. ";

                foreach (var item in items)
                {
                    if (i == 0)
                    {
                        text += item.Beschreibung;
                    }
                    else if (i == items.Count - 1)
                    {
                        text += $", sowie {item.Beschreibung}. ";
                    }
                    else
                    {
                        text += $". {item.Beschreibung}";
                    }

                    i++;
                }

                if (missingDates.Count > 0)
                {
                    text += CreateMissingDatesSpeech(missingDates, menue);
                }
            }
            else
            {
                FehlerTypen.NoSpeisePlan.ToDescription();
            }

            return(new SsmlOutputSpeech {
                Ssml = $"<speak>{text}</speak>"
            });
        }
        public static BodyTemplate2 AddBodyContent(SkillTypen typ, SkillBodyContent content, string title)
        {
            var url = skillParameter.FirstOrDefault(v => v.Typ == typ)?.UrlTemplate;

            return(new BodyTemplate2
            {
                Token = typ.ToString(),
                Title = title,
                BackButton = BackButtonVisibility.Visible,
                Image = new TemplateImage
                {
                    ContentDescription = "_Icon",
                    Sources = new List <ImageSource> {
                        new ImageSource {
                            Url = content.ImageUrl
                        }
                    }
                },
                BackgroundImage = new TemplateImage
                {
                    ContentDescription = "_Icon",
                    Sources = new List <ImageSource> {
                        new ImageSource {
                            Url = url
                        }
                    }
                },
                Content = new TemplateContent
                {
                    Primary = new TemplateText {
                        Text = content.Primaer, Type = TextType.Rich
                    },
                    Secondary = new TemplateText {
                        Text = content.Sekundaer, Type = TextType.Rich
                    },
                    Tertiary = new TemplateText {
                        Text = content.Tertiaer, Type = TextType.Rich
                    }
                }
            });
        }
        private static Dictionary <string, object> CreateSessionAttributes(SkillRequest request, SkillTypen typ, int id, List <ListItem> listItems, DateTime date)
        {
            var listTokens = new List <string>();

            if (listItems != null)
            {
                foreach (var eintrag in listItems)
                {
                    listTokens.Add(eintrag.Token);
                }
            }

            var dictionary = new Dictionary <string, object>
            {
                { SessionAttributes.Id.ToString(), id },
                { SessionAttributes.CurrentListItems.ToString(), listTokens },
                { SessionAttributes.CurrentSkillTyp.ToString(), (int)typ },
                { SessionAttributes.CurrentTagesPlanDate.ToString(), date },
            };

            return(dictionary);
        }