Skip to content

Latest commit

 

History

History
110 lines (85 loc) · 3.76 KB

File metadata and controls

110 lines (85 loc) · 3.76 KB

WebShopProject

WebShopProject is an ASP.NET Core Razor Pages application for an e-commerce platform specializing in prepper supplies. It features Google authentication integration and a development-mode fake login feature.

Features

  • User authentication using Google OpenID Connect
  • Development mode fake login for testing
  • Product catalog with search, filtering, and pagination
  • Shopping cart functionality
  • Order confirmation process
  • API for product retrieval

Technologies Used

  • ASP.NET Core 6.0+
  • Entity Framework Core
  • Razor Pages
  • View Components
  • Microsoft.AspNetCore.Authentication.Cookies
  • Microsoft.AspNetCore.Authorization
  • Microsoft.EntityFrameworkCore
  • Microsoft.IdentityModel.Protocols.OpenIdConnect

Project Structure

  • Program.cs: Application entry point and configuration
  • Data/: Contains database context and data access related classes
    • AppDbContext.cs: Entity Framework DbContext
    • AccessControl.cs: User authentication helper
    • SampleData.cs: Seed data for the application
  • Models/: Contains entity models (Account, Product, Cart, CartItem)
  • Pages/: Razor Pages for the application
    • Index.cshtml/.cshtml.cs: Home page
    • Products.cshtml/.cshtml.cs: Product listing page
    • ProductDetails.cshtml/.cshtml.cs: Individual product details
    • ShoppingCart.cshtml/.cshtml.cs: Shopping cart management
    • OrderConfirmation.cshtml/.cshtml.cs: Order confirmation page
    • FakeLogin.cshtml/.cshtml.cs: Development-only fake login page
    • Error.cshtml/.cshtml.cs: Error handling page
  • Pages/Shared/: Shared layouts and components
    • _Layout.cshtml: Main layout for the application
  • wwwroot/: Static files (CSS, JavaScript, images)
  • Controllers/APIController.cs: API endpoints for product retrieval

Page Descriptions

Index (Home Page)

  • Welcomes the user to the Swedish Prepper Shop
  • Displays a brief description of the shop's offerings
  • Provides a link to the Products page

Products

  • Lists all products with pagination (10 items per page)
  • Allows searching by product name and filtering by category
  • Each product is displayed with an image, name, and price
  • Clicking on a product leads to its details page

Product Details

  • Shows detailed information about a specific product
  • Includes product image, name, category, description, and price
  • Allows adding the product to the shopping cart

Shopping Cart

  • Displays all items currently in the user's cart
  • Shows product image, name, price, and quantity for each item
  • Calculates and displays the total price of all items
  • Provides options to empty the cart or proceed to checkout

Order Confirmation

  • Displays a summary of the ordered items
  • Shows the total price of the order
  • Allows the user to confirm the order and empty the cart

Fake Login (Development Only)

  • Simulates user login without Google authentication
  • Allows selecting from pre-defined user accounts

Error

  • Displays error information when an exception occurs
  • Shows detailed information in the Development environment

Models

Product

public class Product
{
    public int ProductId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    public string? Category { get; set; }
    public string? ImagePath { get; set; }
}

API Endpoints

  • GET /api/products: Retrieve products with optional filtering by name and category, and pagination

Authentication

The application uses Google OpenID Connect for authentication in production. In development mode, a fake login menu is provided for easier testing and development.

Sample Data

The application includes sample data for products and user accounts. This data is seeded when the application runs for the first time.