Implement complete e-commerce functionality with shipping and order management
Features Added: - Standard e-commerce properties (Price, Weight, shipping fields) - Order management with Create/Edit views and shipping information - ShippingRates system for weight-based shipping calculations - Comprehensive test coverage with JWT authentication tests - Sample data seeder with 5 orders demonstrating full workflow - Photo upload functionality for products - Multi-cryptocurrency payment support (BTC, XMR, USDT, etc.) Database Changes: - Added ShippingRates table - Added shipping fields to Orders (Name, Address, City, PostCode, Country) - Renamed properties to standard names (BasePrice to Price, ProductWeight to Weight) - Added UpdatedAt timestamps to models UI Improvements: - Added Create/Edit views for Orders - Added ShippingRates management UI - Updated navigation menu with Shipping option - Enhanced Order Details view with shipping information Sample Data: - 3 Categories (Electronics, Clothing, Books) - 5 Products with various prices - 5 Shipping rates (Royal Mail options) - 5 Orders in different statuses (Pending to Delivered) - 3 Crypto payments demonstrating payment flow Security: - All API endpoints secured with JWT authentication - No public endpoints - client apps must authenticate - Privacy-focused design with minimal data collection Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
72
LittleShop/Areas/Admin/Controllers/AccountController.cs
Normal file
72
LittleShop/Areas/Admin/Controllers/AccountController.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly IAuthService _authService;
|
||||
|
||||
public AccountController(IAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Login()
|
||||
{
|
||||
if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
return RedirectToAction("Index", "Dashboard");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Login(string username, string password)
|
||||
{
|
||||
Console.WriteLine($"Received Username: '{username}', Password: '{password}'");
|
||||
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
ModelState.AddModelError("", "Username and password are required");
|
||||
return View();
|
||||
}
|
||||
|
||||
if (username == "admin" && password == "admin")
|
||||
{
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(ClaimTypes.Name, "admin"),
|
||||
new(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString())
|
||||
};
|
||||
|
||||
var identity = new ClaimsIdentity(claims, "Cookies");
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
|
||||
await HttpContext.SignInAsync("Cookies", principal);
|
||||
return RedirectToAction("Index", "Dashboard");
|
||||
}
|
||||
|
||||
ModelState.AddModelError("", "Invalid username or password");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
await HttpContext.SignOutAsync("Cookies");
|
||||
return RedirectToAction("Login");
|
||||
}
|
||||
|
||||
public IActionResult AccessDenied()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
92
LittleShop/Areas/Admin/Controllers/CategoriesController.cs
Normal file
92
LittleShop/Areas/Admin/Controllers/CategoriesController.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class CategoriesController : Controller
|
||||
{
|
||||
private readonly ICategoryService _categoryService;
|
||||
|
||||
public CategoriesController(ICategoryService categoryService)
|
||||
{
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
return View(categories);
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View(new CreateCategoryDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateCategoryDto model)
|
||||
{
|
||||
Console.WriteLine($"Received Category: Name='{model?.Name}', Description='{model?.Description}'");
|
||||
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
foreach (var error in ModelState)
|
||||
{
|
||||
Console.WriteLine($"ModelState Error - Key: {error.Key}, Errors: {string.Join(", ", error.Value.Errors.Select(e => e.ErrorMessage))}");
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
await _categoryService.CreateCategoryAsync(model);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var category = await _categoryService.GetCategoryByIdAsync(id);
|
||||
if (category == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var model = new UpdateCategoryDto
|
||||
{
|
||||
Name = category.Name,
|
||||
Description = category.Description,
|
||||
IsActive = category.IsActive
|
||||
};
|
||||
|
||||
ViewData["CategoryId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Edit(Guid id, UpdateCategoryDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
ViewData["CategoryId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var success = await _categoryService.UpdateCategoryAsync(id, model);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
await _categoryService.DeleteCategoryAsync(id);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
38
LittleShop/Areas/Admin/Controllers/DashboardController.cs
Normal file
38
LittleShop/Areas/Admin/Controllers/DashboardController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class DashboardController : Controller
|
||||
{
|
||||
private readonly IOrderService _orderService;
|
||||
private readonly IProductService _productService;
|
||||
private readonly ICategoryService _categoryService;
|
||||
|
||||
public DashboardController(
|
||||
IOrderService orderService,
|
||||
IProductService productService,
|
||||
ICategoryService categoryService)
|
||||
{
|
||||
_orderService = orderService;
|
||||
_productService = productService;
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var orders = await _orderService.GetAllOrdersAsync();
|
||||
var products = await _productService.GetAllProductsAsync();
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
|
||||
ViewData["TotalOrders"] = orders.Count();
|
||||
ViewData["TotalProducts"] = products.Count();
|
||||
ViewData["TotalCategories"] = categories.Count();
|
||||
ViewData["TotalRevenue"] = orders.Where(o => o.PaidAt.HasValue).Sum(o => o.TotalAmount);
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
99
LittleShop/Areas/Admin/Controllers/OrdersController.cs
Normal file
99
LittleShop/Areas/Admin/Controllers/OrdersController.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class OrdersController : Controller
|
||||
{
|
||||
private readonly IOrderService _orderService;
|
||||
|
||||
public OrdersController(IOrderService orderService)
|
||||
{
|
||||
_orderService = orderService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var orders = await _orderService.GetAllOrdersAsync();
|
||||
return View(orders.OrderByDescending(o => o.CreatedAt));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(Guid id)
|
||||
{
|
||||
var order = await _orderService.GetOrderByIdAsync(id);
|
||||
if (order == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(order);
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View(new CreateOrderDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateOrderDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var order = await _orderService.CreateOrderAsync(model);
|
||||
return RedirectToAction(nameof(Details), new { id = order.Id });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var order = await _orderService.GetOrderByIdAsync(id);
|
||||
if (order == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(order);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Edit(Guid id, OrderDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var updateDto = new UpdateOrderStatusDto
|
||||
{
|
||||
Status = model.Status,
|
||||
TrackingNumber = model.TrackingNumber,
|
||||
Notes = model.Notes
|
||||
};
|
||||
|
||||
var success = await _orderService.UpdateOrderStatusAsync(id, updateDto);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Details), new { id });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> UpdateStatus(Guid id, UpdateOrderStatusDto model)
|
||||
{
|
||||
var success = await _orderService.UpdateOrderStatusAsync(id, model);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Details), new { id });
|
||||
}
|
||||
}
|
||||
121
LittleShop/Areas/Admin/Controllers/ProductsController.cs
Normal file
121
LittleShop/Areas/Admin/Controllers/ProductsController.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class ProductsController : Controller
|
||||
{
|
||||
private readonly IProductService _productService;
|
||||
private readonly ICategoryService _categoryService;
|
||||
|
||||
public ProductsController(IProductService productService, ICategoryService categoryService)
|
||||
{
|
||||
_productService = productService;
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var products = await _productService.GetAllProductsAsync();
|
||||
return View(products);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Create()
|
||||
{
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
ViewData["Categories"] = categories.Where(c => c.IsActive);
|
||||
return View(new CreateProductDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateProductDto model)
|
||||
{
|
||||
Console.WriteLine($"Received Product: Name='{model?.Name}', Description='{model?.Description}', Price={model?.Price}");
|
||||
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
ViewData["Categories"] = categories.Where(c => c.IsActive);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
await _productService.CreateProductAsync(model);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var product = await _productService.GetProductByIdAsync(id);
|
||||
if (product == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
ViewData["Categories"] = categories.Where(c => c.IsActive);
|
||||
ViewData["ProductId"] = id;
|
||||
|
||||
var model = new UpdateProductDto
|
||||
{
|
||||
Name = product.Name,
|
||||
Description = product.Description,
|
||||
WeightUnit = product.WeightUnit,
|
||||
Weight = product.Weight,
|
||||
Price = product.Price,
|
||||
CategoryId = product.CategoryId,
|
||||
IsActive = product.IsActive
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Edit(Guid id, UpdateProductDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var categories = await _categoryService.GetAllCategoriesAsync();
|
||||
ViewData["Categories"] = categories.Where(c => c.IsActive);
|
||||
ViewData["ProductId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var success = await _productService.UpdateProductAsync(id, model);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> UploadPhoto(Guid id, IFormFile file, string? altText)
|
||||
{
|
||||
if (file != null && file.Length > 0)
|
||||
{
|
||||
await _productService.AddProductPhotoAsync(id, file, altText);
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Edit), new { id });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> DeletePhoto(Guid id, Guid photoId)
|
||||
{
|
||||
await _productService.RemoveProductPhotoAsync(id, photoId);
|
||||
return RedirectToAction(nameof(Edit), new { id });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
await _productService.DeleteProductAsync(id);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
102
LittleShop/Areas/Admin/Controllers/ShippingRatesController.cs
Normal file
102
LittleShop/Areas/Admin/Controllers/ShippingRatesController.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class ShippingRatesController : Controller
|
||||
{
|
||||
private readonly IShippingRateService _shippingRateService;
|
||||
private readonly ILogger<ShippingRatesController> _logger;
|
||||
|
||||
public ShippingRatesController(IShippingRateService shippingRateService, ILogger<ShippingRatesController> logger)
|
||||
{
|
||||
_shippingRateService = shippingRateService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var rates = await _shippingRateService.GetAllShippingRatesAsync();
|
||||
return View(rates);
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View(new CreateShippingRateDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateShippingRateDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var rate = await _shippingRateService.CreateShippingRateAsync(model);
|
||||
_logger.LogInformation("Created shipping rate {RateId}", rate.Id);
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var rate = await _shippingRateService.GetShippingRateByIdAsync(id);
|
||||
if (rate == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var model = new UpdateShippingRateDto
|
||||
{
|
||||
Name = rate.Name,
|
||||
Description = rate.Description,
|
||||
Country = rate.Country,
|
||||
MinWeight = rate.MinWeight,
|
||||
MaxWeight = rate.MaxWeight,
|
||||
Price = rate.Price,
|
||||
MinDeliveryDays = rate.MinDeliveryDays,
|
||||
MaxDeliveryDays = rate.MaxDeliveryDays,
|
||||
IsActive = rate.IsActive
|
||||
};
|
||||
|
||||
ViewData["RateId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Edit(Guid id, UpdateShippingRateDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
ViewData["RateId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var success = await _shippingRateService.UpdateShippingRateAsync(id, model);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Updated shipping rate {RateId}", id);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var success = await _shippingRateService.DeleteShippingRateAsync(id);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Deleted shipping rate {RateId}", id);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
90
LittleShop/Areas/Admin/Controllers/UsersController.cs
Normal file
90
LittleShop/Areas/Admin/Controllers/UsersController.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LittleShop.Services;
|
||||
using LittleShop.DTOs;
|
||||
|
||||
namespace LittleShop.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize(Policy = "AdminOnly")]
|
||||
public class UsersController : Controller
|
||||
{
|
||||
private readonly IAuthService _authService;
|
||||
|
||||
public UsersController(IAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var users = await _authService.GetAllUsersAsync();
|
||||
return View(users);
|
||||
}
|
||||
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateUserDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var user = await _authService.CreateUserAsync(model);
|
||||
if (user == null)
|
||||
{
|
||||
ModelState.AddModelError("", "User with this username already exists");
|
||||
return View(model);
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
var user = await _authService.GetUserByIdAsync(id);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var model = new UpdateUserDto
|
||||
{
|
||||
Username = user.Username,
|
||||
IsActive = user.IsActive
|
||||
};
|
||||
|
||||
ViewData["UserId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Edit(Guid id, UpdateUserDto model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
ViewData["UserId"] = id;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var success = await _authService.UpdateUserAsync(id, model);
|
||||
if (!success)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
await _authService.DeleteUserAsync(id);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
65
LittleShop/Areas/Admin/Views/Account/Login.cshtml
Normal file
65
LittleShop/Areas/Admin/Views/Account/Login.cshtml
Normal file
@@ -0,0 +1,65 @@
|
||||
@model LittleShop.DTOs.LoginDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Admin Login";
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"]</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card mt-5">
|
||||
<div class="card-header text-center">
|
||||
<h4><i class="fas fa-store"></i> LittleShop Admin</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Account" asp-action="Login">
|
||||
@if (ViewData.ModelState[""]?.Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@ViewData.ModelState[""]?.Errors.First().ErrorMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Username</label>
|
||||
<input name="username" id="username" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input name="password" id="password" type="password" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-sign-in-alt"></i> Login
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="mt-3 text-center">
|
||||
<small class="text-muted">Default: admin/admin</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.12/jquery.validate.unobtrusive.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
51
LittleShop/Areas/Admin/Views/Categories/Create.cshtml
Normal file
51
LittleShop/Areas/Admin/Views/Categories/Create.cshtml
Normal file
@@ -0,0 +1,51 @@
|
||||
@model LittleShop.DTOs.CreateCategoryDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create Category";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-plus"></i> Create Category</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Categories" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Name" class="form-label">Name</label>
|
||||
<input name="Name" id="Name" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Description" class="form-label">Description</label>
|
||||
<textarea name="Description" id="Description" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Categories
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Create Category
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
60
LittleShop/Areas/Admin/Views/Categories/Edit.cshtml
Normal file
60
LittleShop/Areas/Admin/Views/Categories/Edit.cshtml
Normal file
@@ -0,0 +1,60 @@
|
||||
@model LittleShop.DTOs.UpdateCategoryDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit Category";
|
||||
var categoryId = ViewData["CategoryId"];
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-edit"></i> Edit Category</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" action="@Url.Action("Edit", new { id = categoryId })">
|
||||
@if (ViewData.ModelState.ErrorCount > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@Html.ValidationSummary()
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Name" class="form-label">Name</label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Description" class="form-label">Description</label>
|
||||
<textarea asp-for="Description" class="form-control" rows="3"></textarea>
|
||||
<span asp-validation-for="Description" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input asp-for="IsActive" class="form-check-input" type="checkbox" />
|
||||
<label asp-for="IsActive" class="form-check-label">
|
||||
Active
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-text text-muted">Inactive categories are hidden from the public catalog</small>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Categories
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
81
LittleShop/Areas/Admin/Views/Categories/Index.cshtml
Normal file
81
LittleShop/Areas/Admin/Views/Categories/Index.cshtml
Normal file
@@ -0,0 +1,81 @@
|
||||
@model IEnumerable<LittleShop.DTOs.CategoryDto>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Categories";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-tags"></i> Categories</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Create")" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Add Category
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Products</th>
|
||||
<th>Created</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var category in Model)
|
||||
{
|
||||
<tr>
|
||||
<td><strong>@category.Name</strong></td>
|
||||
<td>@category.Description</td>
|
||||
<td>
|
||||
<span class="badge bg-info">@category.ProductCount products</span>
|
||||
</td>
|
||||
<td>@category.CreatedAt.ToString("MMM dd, yyyy")</td>
|
||||
<td>
|
||||
@if (category.IsActive)
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-danger">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="@Url.Action("Edit", new { id = category.Id })" class="btn btn-outline-primary">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<form method="post" action="@Url.Action("Delete", new { id = category.Id })" class="d-inline"
|
||||
onsubmit="return confirm('Are you sure you want to delete this category?')">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-tags fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No categories found. <a href="@Url.Action("Create")">Create your first category</a>.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
98
LittleShop/Areas/Admin/Views/Dashboard/Index.cshtml
Normal file
98
LittleShop/Areas/Admin/Views/Dashboard/Index.cshtml
Normal file
@@ -0,0 +1,98 @@
|
||||
@{
|
||||
ViewData["Title"] = "Dashboard";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-tachometer-alt"></i> Dashboard</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-primary mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-shopping-cart"></i> Total Orders
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">@ViewData["TotalOrders"]</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-success mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-box"></i> Total Products
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">@ViewData["TotalProducts"]</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-info mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-tags"></i> Total Categories
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">@ViewData["TotalCategories"]</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-warning mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-pound-sign"></i> Total Revenue
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">£@ViewData["TotalRevenue"]</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-chart-line"></i> Quick Actions</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="list-group list-group-flush">
|
||||
<a href="@Url.Action("Create", "Products")" class="list-group-item list-group-item-action">
|
||||
<i class="fas fa-plus"></i> Add New Product
|
||||
</a>
|
||||
<a href="@Url.Action("Create", "Categories")" class="list-group-item list-group-item-action">
|
||||
<i class="fas fa-plus"></i> Add New Category
|
||||
</a>
|
||||
<a href="@Url.Action("Index", "Orders")" class="list-group-item list-group-item-action">
|
||||
<i class="fas fa-list"></i> View All Orders
|
||||
</a>
|
||||
<a href="@Url.Action("Create", "Users")" class="list-group-item list-group-item-action">
|
||||
<i class="fas fa-user-plus"></i> Add New User
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> System Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Framework:</strong> .NET 9.0</li>
|
||||
<li><strong>Database:</strong> SQLite</li>
|
||||
<li><strong>Authentication:</strong> Cookie-based</li>
|
||||
<li><strong>Crypto Support:</strong> 8 currencies via BTCPay Server</li>
|
||||
<li><strong>API Endpoints:</strong> Available for client integration</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
106
LittleShop/Areas/Admin/Views/Orders/Create.cshtml
Normal file
106
LittleShop/Areas/Admin/Views/Orders/Create.cshtml
Normal file
@@ -0,0 +1,106 @@
|
||||
@model LittleShop.DTOs.CreateOrderDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create Order";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-plus"></i> Create Order</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-user"></i> Customer Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Orders" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="IdentityReference" class="form-label">Customer Reference</label>
|
||||
<input name="IdentityReference" id="IdentityReference" class="form-control" required
|
||||
placeholder="Customer ID or reference" />
|
||||
<small class="text-muted">Anonymous identifier for the customer</small>
|
||||
</div>
|
||||
|
||||
<h6 class="mt-4 mb-3">Shipping Information</h6>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingName" class="form-label">Recipient Name</label>
|
||||
<input name="ShippingName" id="ShippingName" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingAddress" class="form-label">Shipping Address</label>
|
||||
<textarea name="ShippingAddress" id="ShippingAddress" class="form-control" rows="2" required></textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="ShippingCity" class="form-label">City</label>
|
||||
<input name="ShippingCity" id="ShippingCity" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="ShippingPostCode" class="form-label">Post Code</label>
|
||||
<input name="ShippingPostCode" id="ShippingPostCode" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingCountry" class="form-label">Country</label>
|
||||
<input name="ShippingCountry" id="ShippingCountry" class="form-control" value="United Kingdom" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Notes" class="form-label">Order Notes (Optional)</label>
|
||||
<textarea name="Notes" id="Notes" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Create Order
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Order Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Create a new order manually for phone or email orders.</p>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Customer Reference:</strong> Anonymous identifier</li>
|
||||
<li><strong>Shipping Details:</strong> Required for delivery</li>
|
||||
<li><strong>Payment:</strong> Add after order creation</li>
|
||||
<li><strong>Products:</strong> Add items after creation</li>
|
||||
</ul>
|
||||
<small class="text-muted">Orders created here will appear in the orders list with PendingPayment status.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
195
LittleShop/Areas/Admin/Views/Orders/Details.cshtml
Normal file
195
LittleShop/Areas/Admin/Views/Orders/Details.cshtml
Normal file
@@ -0,0 +1,195 @@
|
||||
@model LittleShop.DTOs.OrderDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = $"Order #{Model.Id.ToString().Substring(0, 8)}";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-shopping-cart"></i> Order Details</h1>
|
||||
<p class="text-muted">Order ID: @Model.Id</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Edit", new { id = Model.Id })" class="btn btn-primary">
|
||||
<i class="fas fa-edit"></i> Edit Order
|
||||
</a>
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Order Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>Identity Reference:</strong> @Model.IdentityReference</p>
|
||||
<p><strong>Status:</strong>
|
||||
@{
|
||||
var badgeClass = Model.Status switch
|
||||
{
|
||||
LittleShop.Enums.OrderStatus.PendingPayment => "bg-warning",
|
||||
LittleShop.Enums.OrderStatus.PaymentReceived => "bg-success",
|
||||
LittleShop.Enums.OrderStatus.Processing => "bg-info",
|
||||
LittleShop.Enums.OrderStatus.Shipped => "bg-primary",
|
||||
LittleShop.Enums.OrderStatus.Delivered => "bg-success",
|
||||
LittleShop.Enums.OrderStatus.Cancelled => "bg-danger",
|
||||
_ => "bg-secondary"
|
||||
};
|
||||
}
|
||||
<span class="badge @badgeClass">@Model.Status</span>
|
||||
</p>
|
||||
<p><strong>Total Amount:</strong> £@Model.TotalAmount</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Created:</strong> @Model.CreatedAt.ToString("MMM dd, yyyy HH:mm")</p>
|
||||
@if (Model.PaidAt.HasValue)
|
||||
{
|
||||
<p><strong>Paid:</strong> @Model.PaidAt.Value.ToString("MMM dd, yyyy HH:mm")</p>
|
||||
}
|
||||
@if (Model.ShippedAt.HasValue)
|
||||
{
|
||||
<p><strong>Shipped:</strong> @Model.ShippedAt.Value.ToString("MMM dd, yyyy HH:mm")</p>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(Model.TrackingNumber))
|
||||
{
|
||||
<p><strong>Tracking:</strong> @Model.TrackingNumber</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(Model.Notes))
|
||||
{
|
||||
<div class="mt-3">
|
||||
<strong>Notes:</strong>
|
||||
<p class="text-muted">@Model.Notes</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-truck"></i> Shipping Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>Name:</strong> @Model.ShippingName</p>
|
||||
<p><strong>Address:</strong> @Model.ShippingAddress</p>
|
||||
<p><strong>City:</strong> @Model.ShippingCity</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Post Code:</strong> @Model.ShippingPostCode</p>
|
||||
<p><strong>Country:</strong> @Model.ShippingCountry</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-list"></i> Order Items</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>Quantity</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Items)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.ProductName</td>
|
||||
<td>@item.Quantity</td>
|
||||
<td>£@item.UnitPrice</td>
|
||||
<td><strong>£@item.TotalPrice</strong></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="3">Total</th>
|
||||
<th>£@Model.TotalAmount</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-edit"></i> Update Status</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="@Url.Action("UpdateStatus", new { id = Model.Id })">
|
||||
<div class="mb-3">
|
||||
<label for="Status" class="form-label">Status</label>
|
||||
<select name="Status" class="form-select">
|
||||
<option value="0" selected="@(Model.Status == LittleShop.Enums.OrderStatus.PendingPayment)">Pending Payment</option>
|
||||
<option value="1" selected="@(Model.Status == LittleShop.Enums.OrderStatus.PaymentReceived)">Payment Received</option>
|
||||
<option value="2" selected="@(Model.Status == LittleShop.Enums.OrderStatus.Processing)">Processing</option>
|
||||
<option value="3" selected="@(Model.Status == LittleShop.Enums.OrderStatus.PickingAndPacking)">Picking & Packing</option>
|
||||
<option value="4" selected="@(Model.Status == LittleShop.Enums.OrderStatus.Shipped)">Shipped</option>
|
||||
<option value="5" selected="@(Model.Status == LittleShop.Enums.OrderStatus.Delivered)">Delivered</option>
|
||||
<option value="6" selected="@(Model.Status == LittleShop.Enums.OrderStatus.Cancelled)">Cancelled</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="TrackingNumber" class="form-label">Tracking Number</label>
|
||||
<input name="TrackingNumber" value="@Model.TrackingNumber" class="form-control" placeholder="Royal Mail tracking number" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Notes" class="form-label">Notes</label>
|
||||
<textarea name="Notes" class="form-control" rows="3" placeholder="Additional notes">@Model.Notes</textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Update Order
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (Model.Payments.Any())
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-coins"></i> Crypto Payments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach (var payment in Model.Payments)
|
||||
{
|
||||
<div class="mb-3 p-2 border rounded">
|
||||
<div class="d-flex justify-content-between">
|
||||
<strong>@payment.Currency</strong>
|
||||
<span class="badge bg-info">@payment.Status</span>
|
||||
</div>
|
||||
<small class="text-muted d-block">Required: @payment.RequiredAmount @payment.Currency</small>
|
||||
<small class="text-muted d-block">Paid: @payment.PaidAmount @payment.Currency</small>
|
||||
@if (!string.IsNullOrEmpty(payment.WalletAddress))
|
||||
{
|
||||
<small class="text-muted d-block">Address: @payment.WalletAddress.Substring(0, 10)...</small>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
218
LittleShop/Areas/Admin/Views/Orders/Edit.cshtml
Normal file
218
LittleShop/Areas/Admin/Views/Orders/Edit.cshtml
Normal file
@@ -0,0 +1,218 @@
|
||||
@model LittleShop.DTOs.OrderDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit Order";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-edit"></i> Edit Order #@Model?.Id</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-user"></i> Order Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Orders" asp-action="Edit" asp-route-id="@Model?.Id">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Order ID</label>
|
||||
<input class="form-control" value="@Model?.Id" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Customer Reference</label>
|
||||
<input class="form-control" value="@Model?.IdentityReference" readonly />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h6 class="mt-4 mb-3">Shipping Information</h6>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingName" class="form-label">Recipient Name</label>
|
||||
<input name="ShippingName" id="ShippingName" value="@Model?.ShippingName" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingAddress" class="form-label">Shipping Address</label>
|
||||
<textarea name="ShippingAddress" id="ShippingAddress" class="form-control" rows="2" required>@Model?.ShippingAddress</textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="ShippingCity" class="form-label">City</label>
|
||||
<input name="ShippingCity" id="ShippingCity" value="@Model?.ShippingCity" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="ShippingPostCode" class="form-label">Post Code</label>
|
||||
<input name="ShippingPostCode" id="ShippingPostCode" value="@Model?.ShippingPostCode" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ShippingCountry" class="form-label">Country</label>
|
||||
<input name="ShippingCountry" id="ShippingCountry" value="@Model?.ShippingCountry" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="Status" class="form-label">Order Status</label>
|
||||
<select name="Status" id="Status" class="form-select">
|
||||
<option value="0" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.PendingPayment)">Pending Payment</option>
|
||||
<option value="1" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.PaymentReceived)">Payment Received</option>
|
||||
<option value="2" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.Processing)">Processing</option>
|
||||
<option value="3" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.Shipped)">Shipped</option>
|
||||
<option value="4" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.Delivered)">Delivered</option>
|
||||
<option value="5" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.Cancelled)">Cancelled</option>
|
||||
<option value="6" selected="@(Model?.Status == LittleShop.Enums.OrderStatus.Refunded)">Refunded</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="TrackingNumber" class="form-label">Tracking Number</label>
|
||||
<input name="TrackingNumber" id="TrackingNumber" value="@Model?.TrackingNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Notes" class="form-label">Order Notes</label>
|
||||
<textarea name="Notes" id="Notes" class="form-control" rows="3">@Model?.Notes</textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Details", new { id = Model?.Id })" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Details
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Order Items -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-shopping-cart"></i> Order Items</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (Model?.Items?.Any() == true)
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>Quantity</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Items)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.ProductName</td>
|
||||
<td>@item.Quantity</td>
|
||||
<td>£@item.UnitPrice</td>
|
||||
<td>£@item.TotalPrice</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="3">Total Amount</th>
|
||||
<th>£@Model.TotalAmount</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-muted">No items in this order.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Order Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<dl>
|
||||
<dt>Created</dt>
|
||||
<dd>@Model?.CreatedAt.ToString("dd/MM/yyyy HH:mm")</dd>
|
||||
|
||||
<dt>Updated</dt>
|
||||
<dd>@Model?.UpdatedAt.ToString("dd/MM/yyyy HH:mm")</dd>
|
||||
|
||||
@if (Model?.PaidAt != null)
|
||||
{
|
||||
<dt>Paid</dt>
|
||||
<dd>@Model.PaidAt.Value.ToString("dd/MM/yyyy HH:mm")</dd>
|
||||
}
|
||||
|
||||
@if (Model?.ShippedAt != null)
|
||||
{
|
||||
<dt>Shipped</dt>
|
||||
<dd>@Model.ShippedAt.Value.ToString("dd/MM/yyyy HH:mm")</dd>
|
||||
}
|
||||
|
||||
<dt>Total Amount</dt>
|
||||
<dd class="h5">£@Model?.TotalAmount</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Payment Information -->
|
||||
@if (Model?.Payments?.Any() == true)
|
||||
{
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-credit-card"></i> Payments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach (var payment in Model.Payments)
|
||||
{
|
||||
<div class="mb-2">
|
||||
<span class="badge bg-info">@payment.Currency</span>
|
||||
<span class="badge @(payment.Status == LittleShop.Enums.PaymentStatus.Paid ? "bg-success" : "bg-warning")">
|
||||
@payment.Status
|
||||
</span>
|
||||
<small class="d-block mt-1">Amount: @payment.RequiredAmount</small>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
78
LittleShop/Areas/Admin/Views/Orders/Index.cshtml
Normal file
78
LittleShop/Areas/Admin/Views/Orders/Index.cshtml
Normal file
@@ -0,0 +1,78 @@
|
||||
@model IEnumerable<LittleShop.DTOs.OrderDto>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Orders";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-shopping-cart"></i> Orders</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Create")" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Create Order
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Customer</th>
|
||||
<th>Shipping To</th>
|
||||
<th>Status</th>
|
||||
<th>Total</th>
|
||||
<th>Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var order in Model)
|
||||
{
|
||||
<tr>
|
||||
<td><code>@order.Id.ToString().Substring(0, 8)...</code></td>
|
||||
<td>@order.ShippingName</td>
|
||||
<td>@order.ShippingCity, @order.ShippingCountry</td>
|
||||
<td>
|
||||
@{
|
||||
var badgeClass = order.Status switch
|
||||
{
|
||||
LittleShop.Enums.OrderStatus.PendingPayment => "bg-warning",
|
||||
LittleShop.Enums.OrderStatus.PaymentReceived => "bg-success",
|
||||
LittleShop.Enums.OrderStatus.Processing => "bg-info",
|
||||
LittleShop.Enums.OrderStatus.Shipped => "bg-primary",
|
||||
LittleShop.Enums.OrderStatus.Delivered => "bg-success",
|
||||
LittleShop.Enums.OrderStatus.Cancelled => "bg-danger",
|
||||
_ => "bg-secondary"
|
||||
};
|
||||
}
|
||||
<span class="badge @badgeClass">@order.Status</span>
|
||||
</td>
|
||||
<td><strong>£@order.TotalAmount</strong></td>
|
||||
<td>@order.CreatedAt.ToString("MMM dd, yyyy HH:mm")</td>
|
||||
<td>
|
||||
<a href="@Url.Action("Details", new { id = order.Id })" class="btn btn-sm btn-outline-primary">
|
||||
<i class="fas fa-eye"></i> View
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-shopping-cart fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No orders found yet.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
117
LittleShop/Areas/Admin/Views/Products/Create.cshtml
Normal file
117
LittleShop/Areas/Admin/Views/Products/Create.cshtml
Normal file
@@ -0,0 +1,117 @@
|
||||
@model LittleShop.DTOs.CreateProductDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create Product";
|
||||
var categories = ViewData["Categories"] as IEnumerable<LittleShop.DTOs.CategoryDto>;
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-plus"></i> Create Product</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Products" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Name" class="form-label">Product Name</label>
|
||||
<input name="Name" id="Name" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Description" class="form-label">Description</label>
|
||||
<textarea name="Description" id="Description" class="form-control" rows="4" required></textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="Price" class="form-label">Price (£)</label>
|
||||
<input name="Price" id="Price" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="CategoryId" class="form-label">Category</label>
|
||||
<select name="CategoryId" id="CategoryId" class="form-select" required>
|
||||
<option value="">Select a category</option>
|
||||
@if (categories != null)
|
||||
{
|
||||
@foreach (var category in categories)
|
||||
{
|
||||
<option value="@category.Id">@category.Name</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="Weight" class="form-label">Weight/Volume</label>
|
||||
<input name="Weight" id="Weight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="WeightUnit" class="form-label">Unit</label>
|
||||
<select name="WeightUnit" id="WeightUnit" class="form-select">
|
||||
<option value="0">Unit</option>
|
||||
<option value="1">Micrograms</option>
|
||||
<option value="2">Grams</option>
|
||||
<option value="3">Ounces</option>
|
||||
<option value="4">Pounds</option>
|
||||
<option value="5">Millilitres</option>
|
||||
<option value="6">Litres</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Products
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Create Product
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Product Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Name:</strong> Unique product identifier</li>
|
||||
<li><strong>Description:</strong> Supports Unicode and emojis</li>
|
||||
<li><strong>Price:</strong> Base price in GBP</li>
|
||||
<li><strong>Weight/Volume:</strong> Used for shipping calculations</li>
|
||||
<li><strong>Category:</strong> Product organization</li>
|
||||
</ul>
|
||||
<small class="text-muted">You can add photos after creating the product.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
155
LittleShop/Areas/Admin/Views/Products/Edit.cshtml
Normal file
155
LittleShop/Areas/Admin/Views/Products/Edit.cshtml
Normal file
@@ -0,0 +1,155 @@
|
||||
@model LittleShop.DTOs.UpdateProductDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit Product";
|
||||
var categories = ViewData["Categories"] as IEnumerable<LittleShop.DTOs.CategoryDto>;
|
||||
var productId = ViewData["ProductId"];
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-edit"></i> Edit Product</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" action="@Url.Action("Edit", new { id = productId })">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Name" class="form-label">Product Name</label>
|
||||
<input name="Name" id="Name" value="@Model?.Name" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Description" class="form-label">Description</label>
|
||||
<textarea name="Description" id="Description" class="form-control" rows="4" required>@Model?.Description</textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="Price" class="form-label">Price (£)</label>
|
||||
<input name="Price" id="Price" value="@Model?.Price" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="CategoryId" class="form-label">Category</label>
|
||||
<select name="CategoryId" id="CategoryId" class="form-select" required>
|
||||
<option value="">Select a category</option>
|
||||
@if (categories != null)
|
||||
{
|
||||
@foreach (var category in categories)
|
||||
{
|
||||
<option value="@category.Id" selected="@(Model?.CategoryId == category.Id)">@category.Name</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="Weight" class="form-label">Weight/Volume</label>
|
||||
<input name="Weight" id="Weight" value="@Model?.Weight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="WeightUnit" class="form-label">Unit</label>
|
||||
<select name="WeightUnit" id="WeightUnit" class="form-select">
|
||||
<option value="0" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Unit)">Unit</option>
|
||||
<option value="1" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Micrograms)">Micrograms</option>
|
||||
<option value="2" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Grams)">Grams</option>
|
||||
<option value="3" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Ounces)">Ounces</option>
|
||||
<option value="4" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Pounds)">Pounds</option>
|
||||
<option value="5" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Millilitres)">Millilitres</option>
|
||||
<option value="6" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Litres)">Litres</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input name="IsActive" type="checkbox" class="form-check-input" checked="@(Model?.IsActive == true)" value="true" />
|
||||
<input name="IsActive" type="hidden" value="false" />
|
||||
<label for="IsActive" class="form-check-label">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Products
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Photo Upload Section -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-camera"></i> Product Photos</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="@Url.Action("UploadPhoto", new { id = productId })" enctype="multipart/form-data">
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mb-3">
|
||||
<label for="file" class="form-label">Choose Photo</label>
|
||||
<input name="file" id="file" type="file" class="form-control" accept="image/*" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="mb-3">
|
||||
<label for="altText" class="form-label">Alt Text</label>
|
||||
<input name="altText" id="altText" class="form-control" placeholder="Image description" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-upload"></i> Upload Photo
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Product Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Name:</strong> Product identifier</li>
|
||||
<li><strong>Description:</strong> Supports Unicode and emojis</li>
|
||||
<li><strong>Price:</strong> Base price in GBP</li>
|
||||
<li><strong>Weight/Volume:</strong> For shipping calculations</li>
|
||||
<li><strong>Category:</strong> Product organization</li>
|
||||
<li><strong>Status:</strong> Active products appear in catalog</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
101
LittleShop/Areas/Admin/Views/Products/Index.cshtml
Normal file
101
LittleShop/Areas/Admin/Views/Products/Index.cshtml
Normal file
@@ -0,0 +1,101 @@
|
||||
@model IEnumerable<LittleShop.DTOs.ProductDto>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Products";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-box"></i> Products</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Create")" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Add Product
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<th>Name</th>
|
||||
<th>Category</th>
|
||||
<th>Price</th>
|
||||
<th>Weight</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var product in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@if (product.Photos.Any())
|
||||
{
|
||||
<img src="@product.Photos.First().FilePath" alt="@product.Photos.First().AltText" class="img-thumbnail" style="width: 50px; height: 50px; object-fit: cover;">
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="bg-light d-flex align-items-center justify-content-center" style="width: 50px; height: 50px;">
|
||||
<i class="fas fa-image text-muted"></i>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<strong>@product.Name</strong>
|
||||
<br><small class="text-muted">@product.Description.Substring(0, Math.Min(50, product.Description.Length))@(product.Description.Length > 50 ? "..." : "")</small>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-secondary">@product.CategoryName</span>
|
||||
</td>
|
||||
<td>
|
||||
<strong>£@product.Price</strong>
|
||||
</td>
|
||||
<td>
|
||||
@product.Weight @product.WeightUnit.ToString().ToLower()
|
||||
</td>
|
||||
<td>
|
||||
@if (product.IsActive)
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-danger">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="@Url.Action("Edit", new { id = product.Id })" class="btn btn-outline-primary">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<form method="post" action="@Url.Action("Delete", new { id = product.Id })" class="d-inline"
|
||||
onsubmit="return confirm('Are you sure you want to delete this product?')">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-box fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No products found. <a href="@Url.Action("Create")">Create your first product</a>.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
82
LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml
Normal file
82
LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml
Normal file
@@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - LittleShop Admin</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="@Url.Action("Index", "Dashboard", new { area = "Admin" })">
|
||||
<i class="fas fa-store"></i> LittleShop Admin
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "Dashboard", new { area = "Admin" })">
|
||||
<i class="fas fa-tachometer-alt"></i> Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "Categories", new { area = "Admin" })">
|
||||
<i class="fas fa-tags"></i> Categories
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "Products", new { area = "Admin" })">
|
||||
<i class="fas fa-box"></i> Products
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "Orders", new { area = "Admin" })">
|
||||
<i class="fas fa-shopping-cart"></i> Orders
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "ShippingRates", new { area = "Admin" })">
|
||||
<i class="fas fa-truck"></i> Shipping
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@Url.Action("Index", "Users", new { area = "Admin" })">
|
||||
<i class="fas fa-users"></i> Users
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-user"></i> @User.Identity?.Name
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<form method="post" action="@Url.Action("Logout", "Account", new { area = "Admin" })">
|
||||
<button type="submit" class="dropdown-item">
|
||||
<i class="fas fa-sign-out-alt"></i> Logout
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container-fluid">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
127
LittleShop/Areas/Admin/Views/ShippingRates/Create.cshtml
Normal file
127
LittleShop/Areas/Admin/Views/ShippingRates/Create.cshtml
Normal file
@@ -0,0 +1,127 @@
|
||||
@model LittleShop.DTOs.CreateShippingRateDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create Shipping Rate";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-plus"></i> Create Shipping Rate</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="ShippingRates" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Name" class="form-label">Rate Name</label>
|
||||
<input name="Name" id="Name" class="form-control" required
|
||||
placeholder="e.g., Royal Mail First Class" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Description" class="form-label">Description (Optional)</label>
|
||||
<textarea name="Description" id="Description" class="form-control" rows="2"
|
||||
placeholder="Additional information about this shipping method"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Country" class="form-label">Country</label>
|
||||
<input name="Country" id="Country" class="form-control" value="United Kingdom" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MinWeight" class="form-label">Minimum Weight (grams)</label>
|
||||
<input name="MinWeight" id="MinWeight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MaxWeight" class="form-label">Maximum Weight (grams)</label>
|
||||
<input name="MaxWeight" id="MaxWeight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Price" class="form-label">Price (£)</label>
|
||||
<input name="Price" id="Price" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MinDeliveryDays" class="form-label">Minimum Delivery Days</label>
|
||||
<input name="MinDeliveryDays" id="MinDeliveryDays" type="number" class="form-control" value="1" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MaxDeliveryDays" class="form-label">Maximum Delivery Days</label>
|
||||
<input name="MaxDeliveryDays" id="MaxDeliveryDays" type="number" class="form-control" value="3" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input name="IsActive" type="checkbox" class="form-check-input" checked value="true" />
|
||||
<input name="IsActive" type="hidden" value="false" />
|
||||
<label for="IsActive" class="form-check-label">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Shipping Rates
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Create Shipping Rate
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Weight Guidelines</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6>Common Weight Ranges (in grams):</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Letter:</strong> 0 - 100g</li>
|
||||
<li><strong>Large Letter:</strong> 100 - 750g</li>
|
||||
<li><strong>Small Parcel:</strong> 750 - 2000g</li>
|
||||
<li><strong>Medium Parcel:</strong> 2000 - 10000g</li>
|
||||
<li><strong>Large Parcel:</strong> 10000 - 30000g</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<h6>Delivery Time Examples:</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>First Class:</strong> 1-3 days</li>
|
||||
<li><strong>Second Class:</strong> 2-5 days</li>
|
||||
<li><strong>Express:</strong> 1 day</li>
|
||||
<li><strong>International:</strong> 5-10 days</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
126
LittleShop/Areas/Admin/Views/ShippingRates/Edit.cshtml
Normal file
126
LittleShop/Areas/Admin/Views/ShippingRates/Edit.cshtml
Normal file
@@ -0,0 +1,126 @@
|
||||
@model LittleShop.DTOs.UpdateShippingRateDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit Shipping Rate";
|
||||
var rateId = ViewData["RateId"];
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-edit"></i> Edit Shipping Rate</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" action="@Url.Action("Edit", new { id = rateId })">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Name" class="form-label">Rate Name</label>
|
||||
<input name="Name" id="Name" value="@Model?.Name" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Description" class="form-label">Description (Optional)</label>
|
||||
<textarea name="Description" id="Description" class="form-control" rows="2">@Model?.Description</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Country" class="form-label">Country</label>
|
||||
<input name="Country" id="Country" value="@Model?.Country" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MinWeight" class="form-label">Minimum Weight (grams)</label>
|
||||
<input name="MinWeight" id="MinWeight" value="@Model?.MinWeight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MaxWeight" class="form-label">Maximum Weight (grams)</label>
|
||||
<input name="MaxWeight" id="MaxWeight" value="@Model?.MaxWeight" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Price" class="form-label">Price (£)</label>
|
||||
<input name="Price" id="Price" value="@Model?.Price" type="number" step="0.01" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MinDeliveryDays" class="form-label">Minimum Delivery Days</label>
|
||||
<input name="MinDeliveryDays" id="MinDeliveryDays" value="@Model?.MinDeliveryDays" type="number" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="MaxDeliveryDays" class="form-label">Maximum Delivery Days</label>
|
||||
<input name="MaxDeliveryDays" id="MaxDeliveryDays" value="@Model?.MaxDeliveryDays" type="number" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input name="IsActive" type="checkbox" class="form-check-input" checked="@(Model?.IsActive == true)" value="true" />
|
||||
<input name="IsActive" type="hidden" value="false" />
|
||||
<label for="IsActive" class="form-check-label">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Shipping Rates
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Weight Guidelines</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6>Common Weight Ranges (in grams):</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Letter:</strong> 0 - 100g</li>
|
||||
<li><strong>Large Letter:</strong> 100 - 750g</li>
|
||||
<li><strong>Small Parcel:</strong> 750 - 2000g</li>
|
||||
<li><strong>Medium Parcel:</strong> 2000 - 10000g</li>
|
||||
<li><strong>Large Parcel:</strong> 10000 - 30000g</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<h6>Delivery Time Examples:</h6>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>First Class:</strong> 1-3 days</li>
|
||||
<li><strong>Second Class:</strong> 2-5 days</li>
|
||||
<li><strong>Express:</strong> 1 day</li>
|
||||
<li><strong>International:</strong> 5-10 days</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
102
LittleShop/Areas/Admin/Views/ShippingRates/Index.cshtml
Normal file
102
LittleShop/Areas/Admin/Views/ShippingRates/Index.cshtml
Normal file
@@ -0,0 +1,102 @@
|
||||
@model IEnumerable<LittleShop.DTOs.ShippingRateDto>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Shipping Rates";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-truck"></i> Shipping Rates</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Create")" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Add Shipping Rate
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Country</th>
|
||||
<th>Weight Range (g)</th>
|
||||
<th>Price</th>
|
||||
<th>Delivery Days</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var rate in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<strong>@rate.Name</strong>
|
||||
@if (!string.IsNullOrEmpty(rate.Description))
|
||||
{
|
||||
<br><small class="text-muted">@rate.Description</small>
|
||||
}
|
||||
</td>
|
||||
<td>@rate.Country</td>
|
||||
<td>@rate.MinWeight - @rate.MaxWeight</td>
|
||||
<td>£@rate.Price</td>
|
||||
<td>@rate.MinDeliveryDays - @rate.MaxDeliveryDays days</td>
|
||||
<td>
|
||||
@if (rate.IsActive)
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-danger">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="@Url.Action("Edit", new { id = rate.Id })" class="btn btn-outline-primary">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<form method="post" action="@Url.Action("Delete", new { id = rate.Id })" class="d-inline"
|
||||
onsubmit="return confirm('Are you sure you want to delete this shipping rate?')">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-truck fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No shipping rates configured. <a href="@Url.Action("Create")">Add your first shipping rate</a>.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> Shipping Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Configure shipping rates based on weight ranges and destination countries.</p>
|
||||
<ul>
|
||||
<li>Weight ranges are in grams</li>
|
||||
<li>Rates are automatically calculated based on order weight</li>
|
||||
<li>The cheapest applicable rate is selected for customers</li>
|
||||
<li>Set rates as inactive to temporarily disable them</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
71
LittleShop/Areas/Admin/Views/Users/Create.cshtml
Normal file
71
LittleShop/Areas/Admin/Views/Users/Create.cshtml
Normal file
@@ -0,0 +1,71 @@
|
||||
@model LittleShop.DTOs.CreateUserDto
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create User";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-user-plus"></i> Create User</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-area="Admin" asp-controller="Users" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
@foreach (var error in ViewData.ModelState[""].Errors)
|
||||
{
|
||||
<div>@error.ErrorMessage</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Username" class="form-label">Username</label>
|
||||
<input name="Username" id="Username" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Password" class="form-label">Password</label>
|
||||
<input name="Password" id="Password" type="password" class="form-control" required />
|
||||
<div class="form-text">Minimum 3 characters</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="@Url.Action("Index")" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-left"></i> Back to Users
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i> Create User
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><i class="fas fa-info-circle"></i> User Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Username:</strong> Unique identifier for login</li>
|
||||
<li><strong>Password:</strong> Minimum 3 characters</li>
|
||||
<li><strong>Access:</strong> Full admin panel access</li>
|
||||
</ul>
|
||||
<div class="alert alert-warning mt-3">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
<strong>Note:</strong> This is for staff users only. No email required.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
78
LittleShop/Areas/Admin/Views/Users/Index.cshtml
Normal file
78
LittleShop/Areas/Admin/Views/Users/Index.cshtml
Normal file
@@ -0,0 +1,78 @@
|
||||
@model IEnumerable<LittleShop.DTOs.UserDto>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Users";
|
||||
}
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1><i class="fas fa-users"></i> Users</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="@Url.Action("Create")" class="btn btn-primary">
|
||||
<i class="fas fa-user-plus"></i> Add User
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Created</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var user in Model)
|
||||
{
|
||||
<tr>
|
||||
<td><strong>@user.Username</strong></td>
|
||||
<td>@user.CreatedAt.ToString("MMM dd, yyyy")</td>
|
||||
<td>
|
||||
@if (user.IsActive)
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-danger">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="@Url.Action("Edit", new { id = user.Id })" class="btn btn-outline-primary">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
@if (user.Username != "admin")
|
||||
{
|
||||
<form method="post" action="@Url.Action("Delete", new { id = user.Id })" class="d-inline"
|
||||
onsubmit="return confirm('Are you sure you want to delete this user?')">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-users fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No users found.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
3
LittleShop/Areas/Admin/Views/_ViewStart.cshtml
Normal file
3
LittleShop/Areas/Admin/Views/_ViewStart.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
Reference in New Issue
Block a user