Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan.enger authored and ethan.enger committed Dec 7, 2023
2 parents 0d5b385 + 28cac6f commit 0673241
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
8 changes: 7 additions & 1 deletion MusicApi/Services/InventoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public async Task<bool> Update(string email)
await context.SaveChangesAsync();



foreach (var cuc in cartItems)
{
/*if (cuc.Inventory.IsPurchased == true)
Expand All @@ -62,10 +61,17 @@ public async Task<bool> Update(string email)
InventoryId = (int)cuc.InventoryId,
FinalPrice = cuc.Inventory.Item.SellPrice
};
if (customer.RewardPoints is null)
{
customer.RewardPoints = 0;
}
customer.RewardPoints += (int)cuc.Inventory.Item.SellPrice;
context.PurchaseItems.Add(piuc);
context.CartItems.Remove(cuc);
}

context.Customers.Update(customer);

await context.SaveChangesAsync();

return true;
Expand Down
4 changes: 2 additions & 2 deletions MusicBlazorApp/Pages/BrowseItems.razor
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{
@if (item.Quantity == 0)
{
<img class="card-img-top" src="@item.PrimaryImagePath" alt="@item.ItemName" style="border-radius: 0px; filter: saturate(0);">
<img class="card-img-top" src="@item.PrimaryImagePath" alt="@item.ItemName" style="border-radius: 0px; filter: saturate(0); max-width:288px; max-height:288px;">
<p style="background-color: darkred; color: white; position:absolute; top: 30px; padding: 10px; left: -5px;">Out of Stock</p>
}
else
Expand All @@ -85,7 +85,7 @@
}
else
{
<img class="card-img-top" src="https://dummyimage.com/400x500/595959/fff&text=no_image" alt="@item.ItemName" style="border-radius: 0px;">
<img class="card-img-top" src="css\images\No-Image.png" alt="@item.ItemName" style="border-radius: 0px; max-width:288px; max-height:288px;">
}
</div>
<div class="card-title"><h5 class="m-2">@item.ItemName</h5></div>
Expand Down
9 changes: 5 additions & 4 deletions MusicBlazorApp/Pages/Cart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<tbody>
<tr>
<td>@itemResult.Item.SellPrice</td>
<td><input type="number" min="0" @bind="@itemResult.Quantity" @onclick="CalculateCartTotal" /></td>
<td>$@(itemResult.Item.Quantity * itemResult.Item.SellPrice)</td>
<td>@itemResult.Quantity</td>
<td>$@(itemResult.Quantity * itemResult.Item.SellPrice)</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -111,9 +111,10 @@

public void CalculateCartTotal()
{
CartTotal = 0;
foreach (var itemResult in cartState.SelectedItems)
{
int? qty = itemResult.Item.Quantity;
int? qty = itemResult.Quantity;
decimal? sprice = itemResult.Item.SellPrice;
CartTotal += (qty * sprice);
}
Expand All @@ -123,7 +124,7 @@
{
var request = new AddInventoryRequest(UserEmail);
var response = await httpClient.PatchAsJsonAsync<AddInventoryRequest>($"{config[Constants.ApiEndpoint]}/inventory/{request}", request);
NavManager.NavigateTo(NavManager.Uri, forceLoad: true);
NavManager.NavigateTo("/confirm", forceLoad: true);
}
}

61 changes: 26 additions & 35 deletions MusicBlazorApp/Pages/ConfirmPurchase.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@using MusicApi.Data;
@page "/confirm"

@using MusicApi.Data;
@using MusicBlazorApp.State;
@using MusicApi.Dtos;
@inject HttpClient httpClient;
Expand All @@ -8,45 +10,34 @@
@inject AuthenticationStateProvider auth;


<h3>Confirm Your Purchase</h3>

@if (cartState.SelectedItems is not null)
{
<div style="max-width: 1000px; margin-left: auto; margin-right: auto; margin-bottom: 300px;">
<center>
<h3 class="my-5">Thank you for your order!</h3>

<div class="col-md-9">
<div class="row">
@foreach (var itemResult in cartState.SelectedItems)
{
<div class="row">
<div class="col-xl-4">
<img width="150" class="img-fluid img" src="@Path.Combine("css", "images", "itemImages", $"{itemResult.Item.PrimaryImagePath}")">
<h4>What's Next?</h4>
<p>Now that you have purchased, we will reserve your item for pickup.</p>

<h4><a class=" p-3 pt-1 px-4 red-button mb-5" href="/my-account" sytle="text-decoration: none; text-underline: none;">View Account Information</a></h4></center>

<!-- Visit our Location -->
<div class="button-section mx-5 mt-5">
<div class="location-wrapper d-flex flex-row justify-content-center flex-sm-wrap">
<div class="location-descriptions m-2 p-5 ">
<center><h1 style="font-weight: 900;">Visit our location</h1></center>
<h4>54 N Main St<br /> Ephraim, Utah <br />84337<br /> <br />(435) 111-1234</h4>
</div>
<div class="col-xl-8">
<div class="justify-content-center">
<h3><strong>@itemResult.Item.ItemName</strong></h3>
<p>Condition: @itemResult.StatusName</p>
</div>
<table class="table table-borderless">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">each</th>
<th scope="col">qty</th>
<th scope="col">total</th>
</tr>
</thead>
<tbody>
<tr>
<td>@itemResult.Item.SellPrice</td>
<td><input type="number" min="0" @bind="@itemResult.Quantity" @onclick="CalculateCartTotal" /></td>
<td>$@(itemResult.Item.Quantity * itemResult.Item.SellPrice)</td>
</tr>
</tbody>
</table>
<div class="location-descriptions m-2 p-5">
<img class="map img img-fluid" src="css/images/map.png" style="max-width: 300px;" />
</div>
</div>
<hr />
}
</div>
</div>

</div>
}



@code {
Expand Down Expand Up @@ -84,7 +75,7 @@
{
foreach (var itemResult in cartState.SelectedItems)
{
int? qty = itemResult.Item.Quantity;
int? qty = itemResult.Quantity;
decimal? sprice = itemResult.Item.SellPrice;
CartTotal += (qty * sprice);
}
Expand Down
22 changes: 15 additions & 7 deletions MusicBlazorApp/Pages/MyAccount.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
{

<div style="max-width: 1000px; margin-left: auto; margin-right: auto;">
<h1>Hello @Customer.FirstName</h1>
<h1 class="my-5">Hello @Customer.FirstName</h1>

<div class="row">
<div class="col-md-8">
<div class="col-md-8 d-none">
<div class="border" style="border: solid 1px gray; border-radius: 15px; padding: 50px;">
<h3>Your Upcoming Rentals</h3>
<div style="background-color: #ededed; border-radius: 15px; padding: 40px;">
Expand All @@ -27,7 +27,7 @@
<p>Due Date and Time</p>
</div>
</div>
<div class="border my-5" style="border: solid 1px gray; border-radius: 15px; padding: 50px;">
<div class="border my-5 d-none" style="border: solid 1px gray; border-radius: 15px; padding: 50px;">
<h3>Previous Purchases</h3>
<div style="background-color: #ededed; border-radius: 15px; padding: 40px;">
<h5>Purchase Date</h5>
Expand All @@ -47,11 +47,21 @@
<div class="progress-bar" style=" background-color: darkred;"></div>
</div> *@
<div class="d-flex justify-content-center text-align-center">
<strong>@Customer.RewardPoints points</strong>
@if(Customer.RewardPoints is not null)
{
<h1><strong style="font-weight: 900;">@Customer.RewardPoints points</strong></h1>

}
else
{
<h1><strong style="font-weight: 900;">0 points</strong></h1>

}
</div>
</div>
<div class="my-3" style="border: solid 1px gray; border-radius: 30px; height: 100px; padding: 20px;">
<div class="my-3" style="border: solid 1px gray; border-radius: 30px; padding: 20px;">
<h3>Configure your Profile</h3>
<a href="/Identity/Account/Manage" target="_blank" rel="noopener">Edit Account Information</a>
</div>
</div>
</div>
Expand All @@ -67,7 +77,6 @@
public Customer Customer { get; set; }
public string? name { get; set; }
public string? url { get; set; }
public int ratio { get; set; }

protected override async Task OnInitializedAsync()
{
Expand All @@ -82,7 +91,6 @@
}
Customer = await httpClient.GetFromJsonAsync<Customer>($"{config[Constants.ApiEndpoint]}/customer/{name}");

ratio = (int)(Customer?.RewardPoints / 100);
}

}
14 changes: 4 additions & 10 deletions MusicBlazorApp/Pages/RentRoom.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@




<div class="main-content">
<div>
</div>
</div>

<div class="row mt-5 main-content">

<div class="stepOne">
Expand All @@ -39,7 +33,7 @@
<select class="dropdown" @bind="SelectedRoomId" style="max-width: 300px;">
@foreach (var rm in Rooms)
{
<option value="@rm.Id" @onclick="() => UpdateRoom(rm.Id)">@rm.RoomName</option>
<option value="@rm.Id" @onclick="() => UpdateRoom(rm.Id)" style="font-family:'Arial Rounded MT'">@rm.RoomName</option>
}
</select>
</div>
Expand Down Expand Up @@ -70,13 +64,13 @@
<ul class="list-unstyled">
@if (SelectedRoom is not null && DisplayTimes == true)
{
<h3 class="mt-5">Step Three: Select Time</h3>
<h1 class="mt-5 fw-bold">Step Three: Select Time</h1><hr />
@foreach (var timeframe in SelectedRoom.TimeFrames)
{
@if (timeframe.isAvailable)
{
<button class="m-5 d-block" @onclick="() => UpdateSelectedTimeBlock(timeframe)" style="border: none;">
<li>@timeframe.startTime to @timeframe.endTime</li></button>
<button class="m-5 col-md-2" @onclick="() => UpdateSelectedTimeBlock(timeframe)" style="border: dashed; border-radius:5px;">
<li>@timeframe.startTime.ToString("MM/dd/yyyy hh:mm tt") to @timeframe.endTime.ToString("hh:mm tt")</li></button>
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MusicBlazorApp/Pages/RentRoom.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


.container {
padding: 50px;
padding-top: 50px;
width: 100%;
margin: 0 auto;
max-width: 900px;
Expand Down
2 changes: 1 addition & 1 deletion MusicBlazorApp/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<AuthorizeView>
<Authorized>
<a class="nav-link" href="/cart"><i class="fa-solid fa-cart-shopping" style="font-size: x-large;"></i></a>
<a class="user nav-link" href="Identity/Account/Manage">Hello, @context.User.Identity?.Name!</a>
<a class="user nav-link" href="/my-account">Hello, @context.User.Identity?.Name!</a>
<form method="post" action="Identity/Account/Logout">
<button type="submit" class="nav-link btn btn-link">Log out</button>
</form>
Expand Down
Binary file added MusicBlazorApp/wwwroot/css/images/No-Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0673241

Please sign in to comment.