Files
PowderCoatingLogix/QUICK_REFERENCE.md
2026-04-23 21:38:24 -04:00

6.7 KiB

Quick Reference - Powder Coating Management System

Essential Commands

Database Operations

# Create migration
dotnet ef migrations add MigrationName --project src/PowderCoating.Infrastructure --startup-project src/PowderCoating.Web

# Apply migrations
dotnet ef database update --project src/PowderCoating.Infrastructure --startup-project src/PowderCoating.Web

# Rollback to specific migration
dotnet ef database update MigrationName --project src/PowderCoating.Infrastructure --startup-project src/PowderCoating.Web

# Drop database
dotnet ef database drop --project src/PowderCoating.Infrastructure --startup-project src/PowderCoating.Web

Run Applications

# Web Application
cd src/PowderCoating.Web && dotnet run

# API
cd src/PowderCoating.Api && dotnet run

# With auto-reload
dotnet watch run

Testing

# All tests
dotnet test

# Specific project
dotnet test tests/PowderCoating.UnitTests

# With coverage
dotnet test /p:CollectCoverage=true

Default Credentials

Admin Account:

  • Email: admin@powdercoating.com
  • Password: Admin123!

Key Entities & Relationships

Customer (1) ──── (Many) Jobs
Customer (1) ──── (Many) Quotes
Quote (1) ──────── (1) Job (converted)
Job (1) ──────── (Many) JobItems
Job (1) ──────── (Many) JobPhotos
InventoryItem (1) ─ (Many) JobItems
Equipment (1) ──── (Many) MaintenanceRecords

Job Status Workflow

Pending → Quoted → Approved → InPreparation → Sandblasting → 
MaskingTaping → Cleaning → InOven → Coating → Curing → 
QualityCheck → Completed → ReadyForPickup → Delivered

API Endpoints Quick Reference

Authentication

  • POST /api/auth/login - Login
  • POST /api/auth/register - Register new user
  • POST /api/auth/refresh - Refresh token

Jobs

  • GET /api/jobs - List all jobs
  • GET /api/jobs/{id} - Get specific job
  • POST /api/jobs - Create job
  • PUT /api/jobs/{id} - Update job
  • DELETE /api/jobs/{id} - Delete job
  • PATCH /api/jobs/{id}/status - Update status

Customers

  • GET /api/customers - List all customers
  • GET /api/customers/{id} - Get specific customer
  • POST /api/customers - Create customer
  • PUT /api/customers/{id} - Update customer
  • DELETE /api/customers/{id} - Delete customer

Inventory

  • GET /api/inventory - List inventory items
  • GET /api/inventory/{id} - Get specific item
  • POST /api/inventory - Add inventory item
  • POST /api/inventory/transaction - Record transaction

Configuration Keys

appsettings.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=...;Database=PowderCoatingDb;..."
  },
  "JwtSettings": {
    "SecretKey": "your-secret-key",
    "ExpirationMinutes": 1440
  },
  "AppSettings": {
    "CompanyName": "Your Company",
    "TaxRate": 0.07
  },
  "AI": {
    "OpenAI": {
      "ApiKey": "sk-..."
    }
  }
}

User Roles & Permissions

Role Manage Customers Create Quotes Manage Jobs Manage Inventory Approve Quotes Admin Panel
Administrator
Manager
Employee ⚠️
ShopFloor ⚠️ (view/update status)
ReadOnly (view only)

Common Code Snippets

Get Paged Data

var (items, totalCount) = await _unitOfWork.Jobs.GetPagedAsync(
    pageNumber: 1,
    pageSize: 25,
    filter: j => j.Status == JobStatus.Pending,
    orderBy: q => q.OrderByDescending(j => j.CreatedAt)
);

Create with Transaction

try
{
    await _unitOfWork.BeginTransactionAsync();
    await _unitOfWork.Jobs.AddAsync(job);
    await _unitOfWork.JobItems.AddRangeAsync(items);
    await _unitOfWork.CommitTransactionAsync();
}
catch
{
    await _unitOfWork.RollbackTransactionAsync();
    throw;
}

Map Entity to DTO

var jobDto = _mapper.Map<JobDto>(job);
var jobs = _mapper.Map<List<JobListDto>>(jobList);

File Locations

Component Location
Entities src/PowderCoating.Core/Entities/
DTOs src/PowderCoating.Application/DTOs/
Controllers (Web) src/PowderCoating.Web/Controllers/
Controllers (API) src/PowderCoating.Api/Controllers/
Views src/PowderCoating.Web/Views/
DbContext src/PowderCoating.Infrastructure/Data/
Repositories src/PowderCoating.Infrastructure/Repositories/
Migrations src/PowderCoating.Infrastructure/Migrations/

Environment Variables (Production)

# Connection String
ConnectionStrings__DefaultConnection="Server=...;Database=...;"

# JWT Secret
JwtSettings__SecretKey="production-secret-key-here"

# OpenAI (if using)
AI__OpenAI__ApiKey="sk-..."

# Logging Level
Logging__LogLevel__Default="Warning"

Ports (Default)

  • Web Application: https://localhost:7001
  • API: https://localhost:7002
  • API Swagger: https://localhost:7002

Performance Tips

  1. Use .AsNoTracking() for read-only queries
  2. Use pagination for large datasets
  3. Implement caching for frequently accessed data
  4. Use projection (.Select()) to load only needed fields
  5. Index frequently queried columns
  6. Use eager loading (.Include()) to avoid N+1 queries

Security Checklist

  • Change default admin password
  • Update JWT secret key
  • Set strong password requirements
  • Enable HTTPS in production
  • Configure CORS appropriately
  • Implement rate limiting
  • Store secrets in Azure Key Vault or similar
  • Enable audit logging
  • Implement input validation
  • Use prepared statements (automatic with EF Core)

Deployment Checklist

  • Update connection strings
  • Set environment to "Production"
  • Apply all migrations
  • Configure logging
  • Set up SSL certificate
  • Configure backup strategy
  • Set up monitoring
  • Test all endpoints
  • Update API documentation
  • Train users

Support & Resources

Documentation Files:

  • GETTING_STARTED.md - Initial setup guide
  • DEVELOPMENT.md - Detailed developer guide
  • README.md - Project overview

Online Resources:

Common Issues:

  • Connection problems → Check SQL Server is running
  • Migration errors → Remove last migration and try again
  • Port conflicts → Update launchSettings.json
  • Package errors → Run dotnet restore --force

Pro Tip: Bookmark this file for quick reference during development!