Skip to content

hwp-labs/vivid-foods-admin

Repository files navigation

Vivid Foods (Admin & API)

Vivid Frozen Foods & Drinks

C#

.Net Azure Postgres

Setup

dotnet new mvc -n VividFoods

mkdir VividFoods

dotnet watch run

# http://localhost:8000

Cheatsheet

# Generate gitignore
dotnet new gitignore --force`

# Set user secrets
dotnet user-secrets init

Add IdentityUser

dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore --version 9.0.0
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 9.0.0
dotnet add package Microsoft.EntityFrameworkCore.Design --version 9.0.0

dotnet ef migrations add InitialMigration --output-dir Data/Migrations
dotnet ef database update

dotnet ef migrations remove

dotnet ef database drop
public class IdentityUser
{
    // Primary Key
    public string Id { get; set; }                          // User ID (GUID string by default)

    // Authentication
    public string? UserName { get; set; }                   // Username (unique)
    public string? NormalizedUserName { get; set; }         // Uppercase username for lookups
    public string? Email { get; set; }                      // Email address
    public string? NormalizedEmail { get; set; }            // Uppercase email for lookups
    public bool EmailConfirmed { get; set; }                // Has email been verified?
    public string? PasswordHash { get; set; }               // Hashed password
    public string? SecurityStamp { get; set; }              // Changes when credentials change
    public string? ConcurrencyStamp { get; set; }           // For concurrency control

    // Phone
    public string? PhoneNumber { get; set; }                // Phone number
    public bool PhoneNumberConfirmed { get; set; }          // Has phone been verified?

    // Security
    public bool TwoFactorEnabled { get; set; }              // Is 2FA enabled?
    public DateTimeOffset? LockoutEnd { get; set; }         // When lockout expires (null = not locked)
    public bool LockoutEnabled { get; set; }                // Can this user be locked out?
    public int AccessFailedCount { get; set; }              // Failed login attempts count
}

Contributors