Skip to content

Commit

Permalink
#106 Remove Service
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusMeyer13 committed Mar 10, 2020
1 parent 184a387 commit 0f70194
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
52 changes: 26 additions & 26 deletions PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/NextOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,34 +141,34 @@ public NextOrder(IOptions<BotConfig> config, IBotTelemetryClient telemetryClient
private async Task<DialogTurnResult> 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<Plan>(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<Plan>(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;
Expand Down
32 changes: 16 additions & 16 deletions PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OrderDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ public OrderDialog(IOptions<BotConfig> config, IBotTelemetryClient telemetryClie

private async Task<DialogTurnResult> 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;
// }
//}



Expand Down
30 changes: 15 additions & 15 deletions PlanB.Butler.Bot/PlanB.Butler.Bot/Dialogs/OverviewDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,22 @@ private async Task<DialogTurnResult> 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<string> restaurants = new List<string>();
//var day = plan.Planday[dayId];
Expand Down

0 comments on commit 0f70194

Please sign in to comment.