Skip to content

Commit

Permalink
#109 Restaurant Site activated
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsCD committed Mar 17, 2020
2 parents 63f6fab + b7145d4 commit b6ddab6
Show file tree
Hide file tree
Showing 79 changed files with 3,510 additions and 1,438 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.101
- name: Build with dotnet
run: dotnet build PlanB.Butler.sln --configuration Release

Expand All @@ -23,4 +23,15 @@ jobs:
with:
dotnet-version: 2.2.108
- name: Test with dotnet
run: dotnet test PlanB.Butler.Library/PlanB.Butler.Library.Test/PlanB.Butler.Library.Test.csproj --configuration Release
run: dotnet test PlanB.Butler.Library/PlanB.Butler.Library.Test/PlanB.Butler.Library.Test.csproj --configuration Release --collect:"Code Coverage"

test-service-library:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Test with dotnet
run: dotnet test PlanB.Butler.Services/PlanB.Butler.Services.Test/PlanB.Butler.Services.Test.csproj --configuration Release --collect:"Code Coverage"
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public async Task<IActionResult> Edit(string id, [Bind("Id,CorrelationId,Date,Pr

if (this.ModelState.IsValid)
{

var result = await this.mealService.UpdateMeal(meal);
return this.RedirectToAction(nameof(this.Index));
}
Expand All @@ -94,7 +93,7 @@ public async Task<IActionResult> Edit(string id, [Bind("Id,CorrelationId,Date,Pr
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Meal.</returns>
public async Task<IActionResult> Edit(string? id)
public async Task<IActionResult> Edit(string id)
{
if (string.IsNullOrEmpty(id))
{
Expand All @@ -110,5 +109,42 @@ public async Task<IActionResult> Edit(string? id)

return this.View(meal);
}

/// <summary>
/// Deletes the specified identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>IActionResult.</returns>
public async Task<IActionResult> Delete(string id)
{
if (string.IsNullOrEmpty(id))
{
return this.NotFound();
}

var meal = await this.mealService.GetMeal(id);

if (meal == null)
{
return this.NotFound();
}

return this.View(meal);
}

/// <summary>
/// Deletes the confirmed.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>IActionResult.</returns>
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
await this.mealService.DeleteMeal(id);

return this.RedirectToAction(nameof(this.Index));
}
}
}
24 changes: 21 additions & 3 deletions PlanB.Butler.Admin/PlanB.Butler.Admin/Services/MealService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public MealService(HttpClient httpClient, IConfiguration configuration)
/// <returns>
/// True or false.
/// </returns>
public async Task<bool> CreateMeal(MealViewModel meal)
public async Task<MealViewModel> CreateMeal(MealViewModel meal)
{
Guid correlationId = Guid.NewGuid();
meal.CorrelationId = correlationId;
Expand All @@ -63,8 +63,26 @@ public async Task<bool> CreateMeal(MealViewModel meal)
Util.AddDefaultEsbHeaders(httpRequestMessage, correlationId, this.config["FunctionsKey"]);
var result = await this.httpClient.SendAsync(httpRequestMessage);
result.EnsureSuccessStatusCode();
var success = result.IsSuccessStatusCode;
return success;

MealViewModel responseModel = JsonConvert.DeserializeObject<MealViewModel>(result.Content.ReadAsStringAsync().Result);
return responseModel;
}

/// <summary>
/// Deletes the meal.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>
/// Succes or failure.
/// </returns>
public async Task<bool> DeleteMeal(string id)
{
var uri = this.config["MealsUri"].TrimEnd('/') + "/" + id;

this.httpClient.DefaultRequestHeaders.Add(Constants.FunctionsKeyHeader, this.config["FunctionsKey"]);
var response = await this.httpClient.DeleteAsync(uri);

return response.IsSuccessStatusCode;
}

/// <summary>
Expand Down
50 changes: 50 additions & 0 deletions PlanB.Butler.Admin/PlanB.Butler.Admin/Views/Meal/Delete.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@model PlanB.Butler.Admin.Models.MealViewModel

@{
ViewData["Title"] = "Delete";
}

<h1>Delete</h1>

<h3>Are you sure you want to delete this?</h3>
<div>
<h4>MealViewModel</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Id)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Id)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Date)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Date)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Price)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Price)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Name)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Restaurant)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Restaurant)
</dd>
</dl>

<form asp-action="Delete">
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>
18 changes: 12 additions & 6 deletions PlanB.Butler.Bot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29403.142
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanB.Butler.Bot", "PlanB.Butler.Bot\PlanB.Butler.Bot.csproj", "{C8440EB0-CF33-415D-8B72-12901F76F7C3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanB.Butler.Library", "PlanB.Butler.Library\PlanB.Butler.Library\PlanB.Butler.Library.csproj", "{26210E9D-B09C-4AFA-891B-79CCBE5EC948}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanB.Butler.Library.Test", "PlanB.Butler.Library\PlanB.Butler.Library.Test\PlanB.Butler.Library.Test.csproj", "{03872204-0270-48AF-902B-F7DA07019174}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanB.Butler.Bot", "PlanB.Butler.Bot\PlanB.Butler.Bot\PlanB.Butler.Bot.csproj", "{AD86FDE0-D566-4332-96DF-406C9D7F5710}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanB.Butler.Bot.Test", "PlanB.Butler.Bot\PlanB.Butler.Bot.Test\PlanB.Butler.Bot.Test.csproj", "{43FEFA53-4B93-46E3-AD14-A96439C3FBA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C8440EB0-CF33-415D-8B72-12901F76F7C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8440EB0-CF33-415D-8B72-12901F76F7C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8440EB0-CF33-415D-8B72-12901F76F7C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8440EB0-CF33-415D-8B72-12901F76F7C3}.Release|Any CPU.Build.0 = Release|Any CPU
{26210E9D-B09C-4AFA-891B-79CCBE5EC948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26210E9D-B09C-4AFA-891B-79CCBE5EC948}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26210E9D-B09C-4AFA-891B-79CCBE5EC948}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -27,6 +25,14 @@ Global
{03872204-0270-48AF-902B-F7DA07019174}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03872204-0270-48AF-902B-F7DA07019174}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03872204-0270-48AF-902B-F7DA07019174}.Release|Any CPU.Build.0 = Release|Any CPU
{AD86FDE0-D566-4332-96DF-406C9D7F5710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD86FDE0-D566-4332-96DF-406C9D7F5710}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD86FDE0-D566-4332-96DF-406C9D7F5710}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD86FDE0-D566-4332-96DF-406C9D7F5710}.Release|Any CPU.Build.0 = Release|Any CPU
{43FEFA53-4B93-46E3-AD14-A96439C3FBA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43FEFA53-4B93-46E3-AD14-A96439C3FBA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43FEFA53-4B93-46E3-AD14-A96439C3FBA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43FEFA53-4B93-46E3-AD14-A96439C3FBA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
47 changes: 0 additions & 47 deletions PlanB.Butler.Bot/Bots/TeamsBot.cs

This file was deleted.

39 changes: 0 additions & 39 deletions PlanB.Butler.Bot/Controllers/BotController.cs

This file was deleted.

42 changes: 0 additions & 42 deletions PlanB.Butler.Bot/Dialogs/MainDialog.cs

This file was deleted.

Loading

0 comments on commit b6ddab6

Please sign in to comment.