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.
- 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
- 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
Program.cs: Application entry point and configurationData/: Contains database context and data access related classesAppDbContext.cs: Entity Framework DbContextAccessControl.cs: User authentication helperSampleData.cs: Seed data for the application
Models/: Contains entity models (Account, Product, Cart, CartItem)Pages/: Razor Pages for the applicationIndex.cshtml/.cshtml.cs: Home pageProducts.cshtml/.cshtml.cs: Product listing pageProductDetails.cshtml/.cshtml.cs: Individual product detailsShoppingCart.cshtml/.cshtml.cs: Shopping cart managementOrderConfirmation.cshtml/.cshtml.cs: Order confirmation pageFakeLogin.cshtml/.cshtml.cs: Development-only fake login pageError.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
- Welcomes the user to the Swedish Prepper Shop
- Displays a brief description of the shop's offerings
- Provides a link to the Products page
- 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
- Shows detailed information about a specific product
- Includes product image, name, category, description, and price
- Allows adding the product to the 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
- 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
- Simulates user login without Google authentication
- Allows selecting from pre-defined user accounts
- Displays error information when an exception occurs
- Shows detailed information in the Development environment
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; }
}- GET
/api/products: Retrieve products with optional filtering by name and category, and pagination
The application uses Google OpenID Connect for authentication in production. In development mode, a fake login menu is provided for easier testing and development.
The application includes sample data for products and user accounts. This data is seeded when the application runs for the first time.