Merge pull request #3 from Shchoholiev/feature/SA-55-wishlists

Feature/sa 55 wishlists
This commit is contained in:
Serhii Shchoholiev 2023-10-16 18:20:38 -04:00 committed by GitHub
commit b65e0c556a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 75545 additions and 75292 deletions

View File

@ -0,0 +1,20 @@
namespace ShoppingAssistantWebClient.Web.Models;
public class ProductModel
{
public required string Id {get; set;}
public required string Url {get; set;}
public required string Name {get; set;}
public required string Description {get; set;}
public required double Rating {get; set;}
public required string[] ImagesUrls {get; set;}
public required bool WasOpened {get; set;}
public required string WishlistId {get; set;}
}

View File

@ -0,0 +1,12 @@
namespace ShoppingAssistantWebClient.Web.Models;
public class WishlistModel
{
public required string Id {get; set;}
public required string Name {get; set;}
public required string Type {get; set;}
public required string CreateById {get; set;}
}

View File

@ -0,0 +1,97 @@
@page
@model ShoppingAssistantWebClient.Web.Pages.CartModel
@{
}
<style>
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.product-div {
height: 310px;
width: 200px;
border-radius: 10px;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
position: relative;
padding: 0 10px 0 10px;
margin: 30px;
}
.product-img {
height: 130px;
width: 100%;
align-self: center;
display: block;
margin: 10px;
}
.product-description {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.button-amazon {
display: flex;
justify-content: center;
align-items: center;
background-color: #009FFF;
border: none;
border-radius: 10px;
position: absolute;
width: 90%;
height: 40px;
bottom: 10px;
}
.star {
position: absolute;
bottom: 60px;
}
.rating {
position: absolute;
bottom: 60px;
left: 35px;
height: 16px;
display: flex;
justify-content: center;
align-items: center;
}
.button-row {
display: flex;
align-items:
}
.price-label {
position: absolute;
right: 10px;
font-weight: bold;
font-size: larger;
height: 16px;
bottom: 60px;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<h1 style="text-align: center; margin-bottom: 50px">Cart</h1>
<div class="container">
@foreach (var product in Model.products) {
<div class="product-div">
<img class="product-img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSe7MHcuWUvuNJsttl3MEVxEayUGVNH4tA2Ha0K4szpgKvH7QYuiaBa_hCzUgW96I6LXqM&usqp=CAU">
<label class="product-description">@Html.DisplayFor(modelproduct => product.Description)</label>
<div class="button-row">
<img class="star" src="~/assets/star.png">
<label class="rating">@Html.DisplayFor(modelproduct => product.Rating)</label>
@{
string price = "N/A";
}
<label class="price-label">@price</label>
</div>
<form class="button">
<button class="button-amazon">
<img src="~/assets/amazon.png">
</button>
</form>
</div>
}
</div>

View File

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Authorization.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using ShoppingAssistantWebClient.Web.Models;
namespace ShoppingAssistantWebClient.Web.Pages
{
public class CartModel : PageModel
{
public List<ProductModel> products = new List<ProductModel> {
new ProductModel {Id = "0", Url = "some link", Name = "HDMI", Description = "super mega hdmi cabel", Rating = 3.8, ImagesUrls = new string[] {"link"}, WasOpened = false, WishlistId = "0"},
new ProductModel {Id = "1", Url = "some link", Name = "HDMI", Description = "super mega hdmi cabel", Rating = 3.8, ImagesUrls = new string[] {"link"}, WasOpened = false, WishlistId = "1"},
new ProductModel {Id = "2", Url = "some link", Name = "HDMI", Description = "super mega hdmi cabel", Rating = 3.8, ImagesUrls = new string[] {"link"}, WasOpened = false, WishlistId = "2"}
};
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,75 @@
@page
@model ShoppingAssistantWebClient.Web.Pages.WishlistModel
@{
//Layout = null;
}
<style>
.table-container {
width: 95%;
height: 95%;
display: flex;
justify-content: center;
align-items: center;
margin: auto;
}
.styled-table {
border-collapse: collapse;
width: 100%;
max-width: 100%;
}
.styled-table th {
border-bottom: 1px solid #ddd;
text-align: center;
font-size: larger;
background-color: rgba(0, 159, 255, 0.1);
}
.styled-table td {
border-bottom: 5px solid #FFF;
border-top: 5px solid #FFF;
text-align: center;
font-size: large;
padding: 20px;
background-color: rgba(248, 248, 255, 1);
}
</style>
<h1 style="text-align: center; margin-bottom: 50px">My Wishlist</h1>
<div class="table-container">
@if(!(Model.wishlist is null))
{
<table class="styled-table">
<thead>
<tr>
<th> </th>
<th style="text-align: left;">Chat name</th>
<th>Type</th>
<th>CreatedById</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.wishlist)
{
<tr>
<form method="post" asp-page-handler="Delete" asp-route-id="@item.Id">
<td><input type="image" src="~/assets/x-button.png"></td>
</form>
<td style="text-align: left">@Html.DisplayFor(modelItem => item.Name)</td>
<td>@Html.DisplayFor(modelItem => item.Type)</td>
<td>@Html.DisplayFor(modelItem => item.CreateById)</td>
<form method="post" asp-page="Wishlist">
<td><input type="image" src="~/assets/shopping-cart.png" asp-page-handler="MoveToChat"></td>
</form>
</tr>
}
</tbody>
</table>
}
else
{
<h3>You don't have a wishlist</h3>
}
</div>

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using ShoppingAssistantWebClient.Web.Models;
namespace ShoppingAssistantWebClient.Web.Pages
{
public class WishlistModel : PageModel
{
public List<Models.WishlistModel> wishlist = new List<Models.WishlistModel>{
new Models.WishlistModel {Id = "0", Name = "Chat1", Type="product", CreateById="0"},
new Models.WishlistModel {Id = "1", Name = "Chat2", Type="gift", CreateById="1"},
new Models.WishlistModel {Id = "2", Name = "Chat3", Type="product", CreateById="2"}
};
public void OnGet()
{
}
public void OnPostDelete(string id) {
var item = wishlist.FirstOrDefault(wishlist => wishlist.Id == id);
wishlist.RemoveAt(Int32.Parse(id));
}
public IActionResult OnPostMoveToChat() {
return RedirectToPage("Index");
}
}
}

View File

@ -21,8 +21,8 @@ app.UseStaticFiles();
app.UseRouting();
//app.UseAuthorization();
app.ConfigureGlobalUserMiddleware();
app.UseAuthorization();
//app.ConfigureGlobalUserMiddleware();
app.MapRazorPages();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B