diff --git a/src/webapp/Components/Layout/MainLayout.razor b/src/webapp/Components/Layout/MainLayout.razor index 2b6545f..8696946 100644 --- a/src/webapp/Components/Layout/MainLayout.razor +++ b/src/webapp/Components/Layout/MainLayout.razor @@ -5,8 +5,8 @@
- -

Fashion Store Assistant

+ +

My Company Copilot

diff --git a/src/webapp/Components/Pages/Cart.razor b/src/webapp/Components/Pages/Cart.razor deleted file mode 100644 index 8a00e57..0000000 --- a/src/webapp/Components/Pages/Cart.razor +++ /dev/null @@ -1,585 +0,0 @@ -@page "/cart" -@layout MainLayout -@using dotnetfashionassistant.Models -@using dotnetfashionassistant.Components.Layout -@using dotnetfashionassistant.Services -@inject HttpClient Http -@inject IHttpClientFactory HttpClientFactory -@inject NavigationManager NavigationManager -@inject IJSRuntime JSRuntime -@inject CartUpdateService CartUpdateService -@rendermode InteractiveServer - -Shopping Cart - -
-
-

Your Shopping Cart

-
- - @if (isLoading) - { -
-
- Loading... -
-

Loading your cart...

-
- } - else if (cartItems.Count == 0) - { -
-
- -
-

Your cart is empty

-

Looks like you haven't added any items to your cart yet.

- -
- } - else - { -
-
- @foreach (var item in cartItems) - { -
-
- @item.ProductName -
-

@item.ProductName

-
- Size: @item.Size - Price: $@item.Price.ToString("0.00") -
-
-
- - - -
-
-
-
- -
-
- } -
- -
-
- Items (@cartItems.Sum(i => i.Quantity)): - $@CalculateSubtotal().ToString("0.00") -
-
- Order Total: - $@CalculateSubtotal().ToString("0.00") -
-
- -
- - - -
-
-
- } -
- - - -@code { - private List cartItems = new List(); - private decimal totalCost = 0; - private bool isLoading = true; - private HttpClient client = null!; protected override async Task OnInitializedAsync() - { - client = HttpClientFactory.CreateClient("LocalApi"); - await LoadCart(); - - // Start polling for cart updates - StartCartPolling(); - } - - private System.Threading.Timer? _pollingTimer; - - private async Task LoadCart() - { - isLoading = true; - try - { - var cartSummary = await client.GetFromJsonAsync("api/Cart"); - if (cartSummary != null) - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - } - else - { - cartItems = new List(); - totalCost = 0; - } - } - catch (Exception ex) - { - Console.WriteLine($"Error loading cart: {ex.Message}"); - cartItems = new List(); - totalCost = 0; - } - isLoading = false; - } private string GetProductImageUrl(int productId) - { - // Map product IDs to specific image files that match the product descriptions - switch (productId) - { - case 3: - return "/images/products/navy-blazer.jpeg"; // Navy Single-Breasted Slim Fit Formal Blazer - case 111: - return "/images/products/white-navy-shirt.jpeg"; // White & Navy Blue Slim Fit Printed Casual Shirt - case 116: - return "/images/products/red-checked-shirt.jpeg"; // Red Slim Fit Checked Casual Shirt - case 10: - return "/images/products/denim-jacket.jpeg"; // Navy Blue Washed Denim Jacket - default: - // Fallback to a placeholder if the product ID is not recognized - return $"https://picsum.photos/seed/{productId}/400/228"; - } - }private decimal CalculateSubtotal() - { - return cartItems.Sum(item => item.Quantity * item.Price); - } private async Task IncreaseQuantity(CartItem item) - { - isLoading = true; - try - { - var request = new { Quantity = item.Quantity + 1 }; - var response = await client.PutAsJsonAsync($"api/Cart/{item.ProductId}/size/{item.Size}", request); - - if (response.IsSuccessStatusCode) - { - var cartSummary = await response.Content.ReadFromJsonAsync(); - if (cartSummary != null) - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - - // Update cart counter immediately - await UpdateCartCounterDisplay(); - // Notify other components about cart update - CartUpdateService.NotifyCartUpdated(); - } - } - else - { - var errorMessage = await response.Content.ReadAsStringAsync(); - Console.WriteLine($"Error: {errorMessage}"); - } - } - catch (Exception ex) - { - Console.WriteLine($"Error updating quantity: {ex.Message}"); - } - isLoading = false; - } private async Task DecreaseQuantity(CartItem item) - { - if (item.Quantity <= 1) return; - - isLoading = true; - try - { - var request = new { Quantity = item.Quantity - 1 }; - var response = await client.PutAsJsonAsync($"api/Cart/{item.ProductId}/size/{item.Size}", request); - - if (response.IsSuccessStatusCode) - { - var cartSummary = await response.Content.ReadFromJsonAsync(); - if (cartSummary != null) - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - - // Update cart counter immediately - await UpdateCartCounterDisplay(); - // Notify other components about cart update - CartUpdateService.NotifyCartUpdated(); - } - } - } - catch (Exception ex) - { - Console.WriteLine($"Error updating quantity: {ex.Message}"); - } - isLoading = false; - } private async Task RemoveItem(CartItem item) - { - isLoading = true; - try - { - var response = await client.DeleteAsync($"api/Cart/{item.ProductId}/size/{item.Size}"); - if (response.IsSuccessStatusCode) - { - var cartSummary = await response.Content.ReadFromJsonAsync(); - if (cartSummary != null) - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - - // Update cart counter immediately - await UpdateCartCounterDisplay(); - // Notify other components about cart update - CartUpdateService.NotifyCartUpdated(); - } - } - } - catch (Exception ex) - { - Console.WriteLine($"Error removing item: {ex.Message}"); - } - isLoading = false; - } private async Task ClearCart() - { - isLoading = true; - try - { - var response = await client.DeleteAsync("api/Cart"); - if (response.IsSuccessStatusCode) - { - var cartSummary = await response.Content.ReadFromJsonAsync(); - if (cartSummary != null) - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - } - else - { - cartItems.Clear(); - totalCost = 0; - } - - // Update cart counter immediately (will be 0 since cart is cleared) - await UpdateCartCounterDisplay(); - // Notify other components about cart update - CartUpdateService.NotifyCartUpdated(); - } - } - catch (Exception ex) - { - Console.WriteLine($"Error clearing cart: {ex.Message}"); - } - isLoading = false; - } - - private void NavigateToInventory() - { - NavigationManager.NavigateTo("/inventory"); - } - private void Checkout() - { - // In a real application, this would navigate to a checkout page - // For now, just show an alert - JSRuntime.InvokeVoidAsync("alert", "Checkout functionality is not implemented in this demo."); - } - - // Method to start polling for cart updates - private void StartCartPolling() - { - // Poll every 3 seconds for cart updates - _pollingTimer = new System.Threading.Timer(async _ => - { - await CheckForCartUpdates(); - }, null, TimeSpan.Zero, TimeSpan.FromSeconds(3)); - } - - private async Task CheckForCartUpdates() - { - try - { - var cartSummary = await client.GetFromJsonAsync("api/Cart"); - if (cartSummary != null) - { - // Check if there are any differences between the current cart and the new cart - bool hasChanged = false; - - // Check if item count changed - if (cartSummary.Items.Count != cartItems.Count) - { - hasChanged = true; - } - else - { - // Check for changes in quantity or price of items - foreach (var newItem in cartSummary.Items) - { - var existingItem = cartItems.FirstOrDefault(i => - i.ProductId == newItem.ProductId && i.Size == newItem.Size); - - if (existingItem == null || existingItem.Quantity != newItem.Quantity || existingItem.Price != newItem.Price) - { - hasChanged = true; - break; - } - } - } - - // If cart has changed, update UI and notify components - if (hasChanged) - { - await InvokeAsync(async () => - { - cartItems = cartSummary.Items; - totalCost = cartSummary.TotalCost; - - // Update cart counter immediately - await UpdateCartCounterDisplay(); - // Notify other components about cart update - CartUpdateService.NotifyCartUpdated(); - - StateHasChanged(); - }); - } - } - } - catch (Exception ex) - { - Console.WriteLine($"Error checking for cart updates: {ex.Message}"); - } - } - - // IDisposable implementation to clean up the timer - public void Dispose() - { - _pollingTimer?.Dispose(); - } - - // Method to update the cart counter immediately using JavaScript - private async Task UpdateCartCounterDisplay() - { - try - { - // Calculate the total quantity of items in the cart - int totalQuantity = cartItems?.Sum(item => item.Quantity) ?? 0; - - // Use JavaScript interop to update the cart badge in real-time - await JSRuntime.InvokeVoidAsync("updateCartBadge", totalQuantity); - } - catch - { - // Silently fail if we can't update the counter - } - } -} diff --git a/src/webapp/Components/Pages/Home.razor b/src/webapp/Components/Pages/Home.razor index c69b564..9e0fa71 100644 --- a/src/webapp/Components/Pages/Home.razor +++ b/src/webapp/Components/Pages/Home.razor @@ -30,7 +30,7 @@ {
-

Hello! I'm your AI shopping assistant. How can I help you with your fashion needs today?

+

Hello! I'm your AI assistant. How can I help you today?

} @@ -285,7 +285,7 @@ { chatHistory.Add(new ChatMessage { - Content = "Hello! I'm your AI shopping assistant. How can I help you with your fashion needs today?", + Content = "Hello! I'm your AI assistant. How can I help you today?", IsUser = false, Timestamp = DateTime.Now }); @@ -306,7 +306,7 @@ chatHistory.Clear(); chatHistory.Add(new ChatMessage { - Content = "Hello! I'm your AI shopping assistant. How can I help you with your fashion needs today?", + Content = "Hello! I'm your AI assistant. How can I help you today?", IsUser = false, Timestamp = DateTime.Now }); @@ -331,7 +331,7 @@ // Add a welcome message chatHistory.Add(new ChatMessage { - Content = "Hello! I'm your AI shopping assistant. How can I help you with your fashion needs today?", + Content = "Hello! I'm your AI assistant. How can I help you today?", IsUser = false, Timestamp = DateTime.Now }); diff --git a/src/webapp/Components/Pages/Inventory.razor b/src/webapp/Components/Pages/Inventory.razor deleted file mode 100644 index 76ed345..0000000 --- a/src/webapp/Components/Pages/Inventory.razor +++ /dev/null @@ -1,491 +0,0 @@ -@page "/inventory" -@layout MainLayout -@using dotnetfashionassistant.Models -@using dotnetfashionassistant.Components.Layout -@using dotnetfashionassistant.Services -@inject IHttpClientFactory HttpClientFactory -@inject NavigationManager NavigationManager -@inject IJSRuntime JSRuntime -@inject CartUpdateService CartUpdateService -@rendermode InteractiveServer - -Fashion Store Inventory - -@if (showSuccessToast) -{ -
- -
-} - -
-
-

Fashion Store

-

Browse our latest collection of premium fashion items

- - @if (errorMessage != null) - { - - }
- -
- @foreach (var item in inventory) - { -
-
- @item.ProductName -
-

@item.ProductName

-
$@item.Price.ToString("0.00")
-
- Available Sizes: -
- @foreach (var size in InventoryService.GetSizes()) - { - @if (item.SizeInventory[size] > 0) - { - - @size (@item.SizeInventory[size]) - - } - else - { - @size (0) - } - } -
-
- -
- @{ - var availableSizes = GetAvailableSizes(item); - var hasSizes = availableSizes.Count > 0; - } -
- -
- -
-
- - - -
-
- - -
-
-
- } -
-
- - - -@code { - private List inventory = null!; - private Dictionary selectedSizes = new Dictionary(); - private Dictionary quantities = new Dictionary(); - private bool showSuccessToast = false; - private string? errorMessage = null; - private HttpClient client = null!; - private string lastAddedItem = ""; - - protected override void OnInitialized() - { - inventory = InventoryService.GetInventory(); - client = HttpClientFactory.CreateClient("LocalApi"); - - // Initialize size selections and quantities - foreach (var item in inventory) - { - selectedSizes[item.ProductId] = ""; - quantities[item.ProductId] = 1; - } - } - - private string GetStockLevelClass(int count) - { - if (count == 0) - return "out-of-stock"; - if (count < 6) - return "bg-danger"; - if (count <= 15) - return "bg-warning"; - return "bg-success"; - } - - private List GetAvailableSizes(InventoryItem item) - { - return item.SizeInventory - .Where(s => s.Value > 0) - .Select(s => s.Key) - .ToList(); - } - - private bool CanAddToCart(InventoryItem item) - { - if (!selectedSizes.TryGetValue(item.ProductId, out var selectedSize)) - return false; - - if (string.IsNullOrEmpty(selectedSize) || - !item.SizeInventory.TryGetValue(selectedSize, out var stock)) - return false; - - int qty = GetQuantity(item.ProductId); - return stock >= qty; - } - - private int GetQuantity(int productId) - { - if (quantities.TryGetValue(productId, out int qty)) - return qty; - - quantities[productId] = 1; - return 1; - } - - private void IncreaseQuantity(int productId) - { - int currentQty = GetQuantity(productId); - if (currentQty < 99) // Set a reasonable upper limit - { - quantities[productId] = currentQty + 1; - } - } - - private void DecreaseQuantity(int productId) - { - int currentQty = GetQuantity(productId); - if (currentQty > 1) - { - quantities[productId] = currentQty - 1; - } - } - - private void UpdateQuantity(int productId, int quantity) - { - // Ensure quantity is within valid range - if (quantity < 1) - quantity = 1; - if (quantity > 99) - quantity = 99; - - quantities[productId] = quantity; - } - private string GetProductImageUrl(int productId) - { - // Map product IDs to specific image files that match the product descriptions - switch (productId) - { - case 3: - return "/images/products/navy-blazer.jpeg"; // Navy Single-Breasted Slim Fit Formal Blazer - case 111: - return "/images/products/white-navy-shirt.jpeg"; // White & Navy Blue Slim Fit Printed Casual Shirt - case 116: - return "/images/products/red-checked-shirt.jpeg"; // Red Slim Fit Checked Casual Shirt - case 10: - return "/images/products/denim-jacket.jpeg"; // Navy Blue Washed Denim Jacket - default: - // Fallback to a placeholder if the product ID is not recognized - return $"https://picsum.photos/seed/{productId}/400/228"; - } - } - - private async Task AddToCart(InventoryItem item) - { - errorMessage = null; - if (!selectedSizes.TryGetValue(item.ProductId, out var size) || string.IsNullOrEmpty(size)) - { - errorMessage = "Please select a size first"; - return; - } - - int quantity = GetQuantity(item.ProductId); - - // Check if enough stock is available - if (!item.SizeInventory.TryGetValue(size, out int stock) || stock < quantity) - { - errorMessage = $"Not enough stock. Only {stock} items available"; - return; - } - - try - { - var request = new - { - ProductId = item.ProductId, - Size = size, - Quantity = quantity - }; - - var response = await client.PostAsJsonAsync("api/Cart/add", request); - - if (response.IsSuccessStatusCode) - { - // Set the details of the last added item for the toast notification - lastAddedItem = $"{quantity} x {item.ProductName} (Size: {size})"; - showSuccessToast = true; - - // Reset quantity to 1 after successful add - quantities[item.ProductId] = 1; - - // Update cart counter immediately using JavaScript interop - await UpdateCartCounterDisplay(response); - } - else - { - var error = await response.Content.ReadAsStringAsync(); - errorMessage = $"Failed to add item to cart: {error}"; - } - } - catch (Exception ex) - { - errorMessage = $"An error occurred: {ex.Message}"; - } - } - private async Task UpdateCartCounterDisplay(HttpResponseMessage response) - { - try - { - // Get the updated cart summary from the API response - var cartSummary = await response.Content.ReadFromJsonAsync(); - - // Calculate the new cart count - int newCount = cartSummary?.Items?.Sum(item => item.Quantity) ?? 0; - - // Use JavaScript interop to update the cart badge in real-time - await JSRuntime.InvokeVoidAsync("updateCartBadge", newCount); - - // Notify other components (like MainLayout) about cart update - CartUpdateService.NotifyCartUpdated(); - } - catch (Exception ex) - { - Console.WriteLine($"Error updating cart counter: {ex.Message}"); - // Silently fail if we can't update the counter - } - } -} diff --git a/src/webapp/Controllers/CartController.cs b/src/webapp/Controllers/CartController.cs deleted file mode 100644 index 2497ab8..0000000 --- a/src/webapp/Controllers/CartController.cs +++ /dev/null @@ -1,151 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using dotnetfashionassistant.Models; -using System.Collections.Generic; -using System.Linq; - -namespace dotnetfashionassistant.Controllers -{ - [ApiController] - [Route("api/[controller]")] - [Produces("application/json")] - public class CartController : ControllerBase - { /// - /// Gets all items in the shopping cart along with the total cost - /// - /// A cart summary containing items and total cost - [HttpGet] - [ProducesResponseType(typeof(CartSummary), 200)] - public ActionResult GetCart() - { - return Ok(CartService.GetCartSummary()); - } /// - /// Adds an item to the shopping cart - /// - /// The item to add to the cart - /// The updated cart summary with total cost - [HttpPost("add")] - [ProducesResponseType(typeof(CartSummary), 200)] - [ProducesResponseType(400)] - public ActionResult AddToCart(AddToCartRequest request) - { - // Validate request - if (request.Quantity <= 0) - { - return BadRequest("Quantity must be greater than zero"); - } - - // Check if the product exists and is in stock - var product = InventoryService.GetInventory().FirstOrDefault(i => i.ProductId == request.ProductId); - if (product == null) - { - return BadRequest("Product not found"); - } - - if (!product.SizeInventory.TryGetValue(request.Size, out int stock)) - { - return BadRequest($"Size {request.Size} not available for this product"); - } - - if (stock < request.Quantity) - { - return BadRequest($"Not enough stock. Only {stock} items available"); - } // Add to cart - CartService.AddToCart(request.ProductId, product.ProductName, request.Size, request.Quantity, product.Price); - - return Ok(CartService.GetCartSummary()); - } /// - /// Updates the quantity of an item in the cart - /// - /// The product ID - /// The product size - /// The update quantity request - /// The updated cart summary with total cost - [HttpPut("{productId}/size/{size}")] - [ProducesResponseType(typeof(CartSummary), 200)] - [ProducesResponseType(400)] - [ProducesResponseType(404)] - public ActionResult UpdateCartItemQuantity(int productId, string size, UpdateQuantityRequest request) - { - // Check if trying to update to a positive quantity - if (request.Quantity > 0) - { - // Check if the product exists and has enough stock - var product = InventoryService.GetInventory().FirstOrDefault(i => i.ProductId == productId); - if (product == null) - { - return BadRequest("Product not found"); - } - - if (!product.SizeInventory.TryGetValue(size, out int stock)) - { - return BadRequest($"Size {size} not available for this product"); - } - - if (stock < request.Quantity) - { - return BadRequest($"Not enough stock. Only {stock} items available"); - } - } // Update the cart - bool success = CartService.UpdateCartItemQuantity(productId, size, request.Quantity); - if (!success) - { - return NotFound("Item not found in cart"); - } - - return Ok(CartService.GetCartSummary()); - } /// - /// Removes an item from the cart - /// - /// The product ID - /// The product size - /// The updated cart summary with total cost - [HttpDelete("{productId}/size/{size}")] - [ProducesResponseType(typeof(CartSummary), 200)] - [ProducesResponseType(404)] - public ActionResult RemoveFromCart(int productId, string size) - { bool success = CartService.RemoveFromCart(productId, size); - if (!success) - { - return NotFound("Item not found in cart"); - } - - return Ok(CartService.GetCartSummary()); - } /// - /// Clears all items from the cart - /// - /// Empty cart summary with zero total cost - [HttpDelete] - [ProducesResponseType(typeof(CartSummary), 200)] - public ActionResult ClearCart() - { - CartService.ClearCart(); - return Ok(CartService.GetCartSummary()); - } - } - - public class AddToCartRequest - { - /// - /// The product ID to add to the cart - /// - public int ProductId { get; set; } - - /// - /// The size of the product (e.g., XS, S, M, L, XL, XXL, XXXL) - /// - public required string Size { get; set; } - - /// - /// The quantity to add - /// - public int Quantity { get; set; } - } - - public class UpdateQuantityRequest - { - /// - /// The new quantity for the cart item - /// - public int Quantity { get; set; } - } -} diff --git a/src/webapp/Controllers/InventoryController.cs b/src/webapp/Controllers/InventoryController.cs deleted file mode 100644 index 3f642c1..0000000 --- a/src/webapp/Controllers/InventoryController.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using dotnetfashionassistant.Models; -using System.Collections.Generic; -using System.Linq; - -namespace dotnetfashionassistant.Controllers -{ - [ApiController] - [Route("api/[controller]")] - [Produces("application/json")] - public class InventoryController : ControllerBase - { - /// - /// Gets all inventory items - /// - /// A list of all inventory items with their sizes and quantities - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public ActionResult> GetInventory() - { - return Ok(InventoryService.GetInventory()); - } - - /// - /// Gets a specific inventory item by product ID - /// - /// The product ID to look up - /// The inventory item matching the specified ID - [HttpGet("{id}")] - [ProducesResponseType(typeof(InventoryItem), 200)] - [ProducesResponseType(404)] - public ActionResult GetInventoryItem(int id) - { - var item = InventoryService.GetInventory().FirstOrDefault(i => i.ProductId == id); - - if (item == null) - { - return NotFound(); - } - - return Ok(item); - } - - /// - /// Gets inventory count for a specific product and size - /// - /// The product ID - /// The size to check (e.g., XS, S, M, L, XL, XXL, XXXL) - /// The inventory count for the specified product and size - [HttpGet("{id}/size/{size}")] - [ProducesResponseType(typeof(SizeInventoryResponse), 200)] - [ProducesResponseType(404)] - public ActionResult GetSizeInventory(int id, string size) - { - var item = InventoryService.GetInventory().FirstOrDefault(i => i.ProductId == id); - - if (item == null) - { - return NotFound("Product not found"); - } - - if (!item.SizeInventory.TryGetValue(size.ToUpper(), out var count)) - { - return NotFound($"Size {size} not found for product {id}"); - } - - return Ok(new SizeInventoryResponse - { - ProductId = id, - ProductName = item.ProductName, - Size = size.ToUpper(), - Count = count - }); - } - - /// - /// Gets all available sizes - /// - /// A list of available sizes - [HttpGet("sizes")] - [ProducesResponseType(typeof(IEnumerable), 200)] - public ActionResult> GetSizes() - { - return Ok(InventoryService.GetSizes()); - } - } /// - /// Represents the response for a size inventory query - /// - public class SizeInventoryResponse - { - /// - /// The product ID - /// - public int ProductId { get; set; } - - /// - /// The product name - /// - public required string ProductName { get; set; } - - /// - /// The size being queried (e.g., XS, S, M, L, XL, XXL, XXXL) - /// - public required string Size { get; set; } - - /// - /// The inventory count for the specified product and size - /// - public int Count { get; set; } - } -} diff --git a/src/webapp/Models/Inventory.cs b/src/webapp/Models/Inventory.cs deleted file mode 100644 index df99034..0000000 --- a/src/webapp/Models/Inventory.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Collections.Generic; - -namespace dotnetfashionassistant.Models -{ public class InventoryItem - { - public int ProductId { get; set; } - public required string ProductName { get; set; } - public Dictionary SizeInventory { get; set; } - public decimal Price { get; set; } - - public InventoryItem() - { - SizeInventory = new Dictionary(); - Price = 29.99m; // Default price if not specified - } - } - - public static class InventoryService - { - private static readonly List Sizes = new List { "XS", "S", "M", "L", "XL", "XXL", "XXXL" }; - - public static List GetInventory() - { - // Create dummy inventory data - var inventory = new List(); - // Navy Formal Blazer - var blazer = new InventoryItem - { - ProductId = 3, - ProductName = "Navy Single-Breasted Slim Fit Formal Blazer", - Price = 89.99m, - SizeInventory = new Dictionary - { - { "XS", 0 }, - { "S", 0 }, - { "M", 0 }, - { "L", 0 }, - { "XL", 0 }, - { "XXL", 0 }, - { "XXXL", 0 } - } - }; - // White & Navy Blue Shirt - var whiteNavyShirt = new InventoryItem - { - ProductId = 111, - ProductName = "White & Navy Blue Slim Fit Printed Casual Shirt", - Price = 34.99m, - SizeInventory = new Dictionary - { - { "XS", 8 }, - { "S", 15 }, - { "M", 0 }, - { "L", 18 }, - { "XL", 12 }, - { "XXL", 0 }, - { "XXXL", 4 } - } - }; - // Red Checked Shirt - var redShirt = new InventoryItem - { - ProductId = 116, - ProductName = "Red Slim Fit Checked Casual Shirt", - Price = 39.99m, - SizeInventory = new Dictionary - { - { "XS", 10 }, - { "S", 18 }, - { "M", 22 }, - { "L", 16 }, - { "XL", 14 }, - { "XXL", 7 }, - { "XXXL", 5 } - } - }; - // Navy Blue Denim Jacket - var denimJacket = new InventoryItem - { - ProductId = 10, - ProductName = "Navy Blue Washed Denim Jacket", - Price = 59.99m, - SizeInventory = new Dictionary - { - { "XS", 6 }, - { "S", 14 }, - { "M", 19 }, - { "L", 17 }, - { "XL", 11 }, - { "XXL", 9 }, - { "XXXL", 4 } - } - }; - - inventory.Add(blazer); - inventory.Add(whiteNavyShirt); - inventory.Add(redShirt); - inventory.Add(denimJacket); - - return inventory; - } - - public static List GetSizes() - { - return Sizes; - } - } -} diff --git a/src/webapp/Models/ShoppingCart.cs b/src/webapp/Models/ShoppingCart.cs deleted file mode 100644 index 4823aa4..0000000 --- a/src/webapp/Models/ShoppingCart.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace dotnetfashionassistant.Models -{ - public class CartSummary - { - public List Items { get; set; } = new(); - public decimal TotalCost { get; set; } - } - - public class CartItem - { - public int ProductId { get; set; } - public required string ProductName { get; set; } - public required string Size { get; set; } - public int Quantity { get; set; } - public decimal Price { get; set; } - } public static class CartService - { - // In-memory cart storage - in a real application, this would use session state or a database - private static readonly List Cart = new(); - - /// - /// Gets all items currently in the cart - /// - public static List GetCart() - { - return Cart; - } - - /// - /// Gets the cart summary including items and total cost - /// - /// A CartSummary containing items and total cost - public static CartSummary GetCartSummary() - { - decimal totalCost = Cart.Sum(item => item.Quantity * item.Price); - - return new CartSummary - { - Items = Cart, - TotalCost = totalCost - }; - }/// - /// Adds an item to the cart or increases quantity if it already exists - /// - public static void AddToCart(int productId, string productName, string size, int quantity, decimal price) - { - // Check if the item already exists in the cart with the same product ID and size - var existingItem = Cart.FirstOrDefault(item => item.ProductId == productId && item.Size == size); - - if (existingItem != null) - { - // If item exists, just update the quantity - existingItem.Quantity += quantity; - } - else - { - // Add new item to the cart - Cart.Add(new CartItem - { - ProductId = productId, - ProductName = productName, - Size = size, - Quantity = quantity, - Price = price - }); - } - } - - /// - /// Updates the quantity of an item in the cart - /// - public static bool UpdateCartItemQuantity(int productId, string size, int quantity) - { - var existingItem = Cart.FirstOrDefault(item => item.ProductId == productId && item.Size == size); - - if (existingItem == null) - { - return false; - } - - if (quantity <= 0) - { - // If quantity is zero or negative, remove the item - return RemoveFromCart(productId, size); - } - - existingItem.Quantity = quantity; - return true; - } - - /// - /// Removes an item from the cart - /// - public static bool RemoveFromCart(int productId, string size) - { - var existingItem = Cart.FirstOrDefault(item => item.ProductId == productId && item.Size == size); - - if (existingItem == null) - { - return false; - } - - Cart.Remove(existingItem); - return true; - } - - /// - /// Clears all items from the cart - /// - public static void ClearCart() - { - Cart.Clear(); - } - } -} diff --git a/src/webapp/wwwroot/images/obungilogo.png b/src/webapp/wwwroot/images/obungilogo.png new file mode 100644 index 0000000..659f74e Binary files /dev/null and b/src/webapp/wwwroot/images/obungilogo.png differ