Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron.allen authored and aaron.allen committed Mar 18, 2024
2 parents 79d4500 + c1dd4ab commit fe2aefb
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace KakeysBakeryClassLib.Services.Interfaces;

public interface IBaseGoodService
{
public Task<List<Basegood>> GetBasegoodsFromTypeAsync(int BaseGoodTypeId);
public Task<List<Basegood>> GetBaseGoodListAsync();
public Task<Basegood?> GetBaseGoodAsync(int id);
public Task CreateBaseGoodAsync(Basegood basegood);
Expand Down
4 changes: 4 additions & 0 deletions KakeysBakery.Tests/BaseGoodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ namespace KakeysBakeryTests;

public class BaseGoodTests : IClassFixture<BakeryFactory>
{

/// <summary>
/// ///////////////////////////////////////////////////////////////////test GetBasegoodsFromTypeAsync////////////////////////////////////////
/// </summary>
public HttpClient client { get; set; }
public BaseGoodTests(BakeryFactory Factory)
{
Expand Down
2 changes: 1 addition & 1 deletion KakeysBakery/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<body>
<Routes />
@* <script src="_framework/blazor.web.js"></script> *@
<script src="_framework/blazor.web.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>

Expand Down
33 changes: 29 additions & 4 deletions KakeysBakery/Components/Pages/Order.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,58 @@
@inject ICustomerService customer
@inject IBaseGoodTypeService basegoodtype

@rendermode InteractiveServer

<h3>Order</h3>

<div class="mt-5 bg-light border vh-100">
<div class="d-flex flex-wrap justify-content-between p-5 mt-5">
@if (basegoodtypes != null)
{
@for (int i = 0; i < basegoodtypes.Count; i++)
@foreach(Basegoodtype basegoodtype in basegoodtypes)
{
<div class="p-3 d-flex flex-column position-relative" style="width: 30rem;">

<div class="p-3 d-flex flex-column position-relative" style="width: 30rem;">
<img class="imgbutton img-fluid img-thumbnail rounded-5 shadow" src="images/SweetnessCupcakes.png">
<button class="btn cartbutton"><i class="bi bi-cart-plus h1 px-3 cart" /></button>
<p>@basegoodtypes[i].Basegood</p>
<button @onclick="() => BaseGoodClicked(basegoodtype.Id)" class="btn cartbutton"><i class="bi bi-cart-plus h1 px-3 cart" /></button>
<p>@basegoodtype.Basegood</p>
</div>

}
}
else
{
<p>Loading products, please wait</p>
}
</div>
@if (baseGoodDetails is not null)
{
<select>
<option> --- </option>
@foreach (Basegood basegoods in baseGoodDetails)
{
<option>@basegoods.Flavor.Flavorname</option>
}
</select>

}
</div>


@code {
List<Basegood>? baseGoodDetails;
int displayNum = 0;

public async Task BaseGoodClicked(int basegoodtypeid)
{
baseGoodDetails = await basegood.GetBasegoodsFromTypeAsync(basegoodtypeid);
}

public List<Basegoodtype>? basegoodtypes;

override protected async Task OnInitializedAsync()
{
basegoodtypes = await basegoodtype.GetBaseGoodTypeListAsync();
}

}
2 changes: 2 additions & 0 deletions KakeysBakery/Components/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
@using KakeysBakery
@using KakeysBakery.Components

@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
11 changes: 11 additions & 0 deletions KakeysBakery/Services/BaseGoodService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,15 @@ public Task UpdateBaseGoodAsync(Basegood basegood)
catch { }
return Task.CompletedTask;
}


public async Task<List<Basegood>> GetBasegoodsFromTypeAsync(int BasegoodTypeId)
{
try
{
return await _context.Basegoods.Where(i => i.Pastryid==BasegoodTypeId).Include(i => i.Flavor).ToListAsync();
}
catch { return new List<Basegood>(); }

}
}

0 comments on commit fe2aefb

Please sign in to comment.