From 0f701948eeb0e072ad80695dffe07ebcbca284a6 Mon Sep 17 00:00:00 2001 From: Markus Meyer Date: Tue, 10 Mar 2020 10:11:19 +0100 Subject: [PATCH] #106 Remove Service --- .../PlanB.Butler.Bot/Dialogs/NextOrder.cs | 52 +++++++++---------- .../PlanB.Butler.Bot/Dialogs/OrderDialog.cs | 32 ++++++------ .../Dialogs/OverviewDialog.cs | 30 +++++------ 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/NextOrder.cs b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/NextOrder.cs index a523c5c..6af6549 100644 --- a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/NextOrder.cs +++ b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/NextOrder.cs @@ -141,34 +141,34 @@ public NextOrder(IOptions config, IBotTelemetryClient telemetryClient private async Task CompanyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Get the Plan - //try - //{ - // string food = BotMethods.GetDocument("eatingplan", "ButlerOverview.json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey); - // plan = JsonConvert.DeserializeObject(food); - // dayId = plan.Planday.FindIndex(x => x.Name == DateTime.Now.DayOfWeek.ToString().ToLower()); - // valid = true; - //} - //catch - //{ - // valid = false; - //} - - IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); - var meals = await mealService.GetMeals(string.Empty, string.Empty); - var mealEnumerator = meals.GetEnumerator(); - this.planDay = new PlanDay(); - while (mealEnumerator.MoveNext()) + try { - if (string.IsNullOrEmpty(this.planDay.Restaurant1)) - { - this.planDay.Restaurant1 = mealEnumerator.Current.Restaurant; - } - - if (string.IsNullOrEmpty(this.planDay.Restaurant2) && this.planDay.Restaurant1 != mealEnumerator.Current.Restaurant) - { - this.planDay.Restaurant2 = mealEnumerator.Current.Restaurant; - } + string food = BotMethods.GetDocument("eatingplan", "ButlerOverview.json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey); + plan = JsonConvert.DeserializeObject(food); + dayId = plan.Planday.FindIndex(x => x.Name == DateTime.Now.DayOfWeek.ToString().ToLower()); + valid = true; } + catch + { + valid = false; + } + + //IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); + //var meals = await mealService.GetMeals(string.Empty, string.Empty); + //var mealEnumerator = meals.GetEnumerator(); + //this.planDay = new PlanDay(); + //while (mealEnumerator.MoveNext()) + //{ + // if (string.IsNullOrEmpty(this.planDay.Restaurant1)) + // { + // this.planDay.Restaurant1 = mealEnumerator.Current.Restaurant; + // } + + // if (string.IsNullOrEmpty(this.planDay.Restaurant2) && this.planDay.Restaurant1 != mealEnumerator.Current.Restaurant) + // { + // this.planDay.Restaurant2 = mealEnumerator.Current.Restaurant; + // } + //} stepContext.Values["name"] = stepContext.Context.Activity.From.Name; diff --git a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OrderDialog.cs b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OrderDialog.cs index efaaa29..9fd9367 100644 --- a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OrderDialog.cs +++ b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OrderDialog.cs @@ -70,22 +70,22 @@ public OrderDialog(IOptions config, IBotTelemetryClient telemetryClie private async Task TimeDayStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { - IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); - var meals = await mealService.GetMeals(string.Empty, string.Empty); - var mealEnumerator = meals.GetEnumerator(); - PlanDay day = new PlanDay(); - while (mealEnumerator.MoveNext()) - { - if (string.IsNullOrEmpty(day.Restaurant1)) - { - day.Restaurant1 = mealEnumerator.Current.Restaurant; - } - - if (string.IsNullOrEmpty(day.Restaurant2) && day.Restaurant1 != mealEnumerator.Current.Restaurant) - { - day.Restaurant2 = mealEnumerator.Current.Restaurant; - } - } + //IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); + //var meals = await mealService.GetMeals(string.Empty, string.Empty); + //var mealEnumerator = meals.GetEnumerator(); + //PlanDay day = new PlanDay(); + //while (mealEnumerator.MoveNext()) + //{ + // if (string.IsNullOrEmpty(day.Restaurant1)) + // { + // day.Restaurant1 = mealEnumerator.Current.Restaurant; + // } + + // if (string.IsNullOrEmpty(day.Restaurant2) && day.Restaurant1 != mealEnumerator.Current.Restaurant) + // { + // day.Restaurant2 = mealEnumerator.Current.Restaurant; + // } + //} diff --git a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OverviewDialog.cs b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OverviewDialog.cs index 575c3eb..d510815 100644 --- a/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OverviewDialog.cs +++ b/PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OverviewDialog.cs @@ -176,22 +176,22 @@ private async Task InitialStepAsync(WaterfallStepContext stepC valid = false; } - IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); - var meals = await mealService.GetMeals(string.Empty, string.Empty); - var mealEnumerator = meals.GetEnumerator(); - PlanDay day = new PlanDay(); - while (mealEnumerator.MoveNext()) - { - if (string.IsNullOrEmpty(day.Restaurant1)) - { - day.Restaurant1 = mealEnumerator.Current.Restaurant; - } + //IMealService mealService = new MealService(this.clientFactory.CreateClient(), this.botConfig.Value); + //var meals = await mealService.GetMeals(string.Empty, string.Empty); + //var mealEnumerator = meals.GetEnumerator(); + //PlanDay day = new PlanDay(); + //while (mealEnumerator.MoveNext()) + //{ + // if (string.IsNullOrEmpty(day.Restaurant1)) + // { + // day.Restaurant1 = mealEnumerator.Current.Restaurant; + // } - if (string.IsNullOrEmpty(day.Restaurant2) && day.Restaurant1 != mealEnumerator.Current.Restaurant) - { - day.Restaurant2 = mealEnumerator.Current.Restaurant; - } - } + // if (string.IsNullOrEmpty(day.Restaurant2) && day.Restaurant1 != mealEnumerator.Current.Restaurant) + // { + // day.Restaurant2 = mealEnumerator.Current.Restaurant; + // } + //} List restaurants = new List(); //var day = plan.Planday[dayId];