249128e852
Root cause: fingerprint-based removal failed on databases seeded with older code (different emails/SKUs); plus Vendors, Named Ovens, and Appointments had no removal path at all. - Add ForceRemoveAll flag to RemoveSeedDataOptions: when true, all removal blocks delete by CompanyId instead of fingerprint matching - Customers block: ForceRemoveAll deletes all company customers - Workers block: ForceRemoveAll deletes all users with CompanyRole=Worker - New Vendors block (triggered by options.Vendors || ForceRemoveAll) - New NamedOvens (OvenCost) block (triggered by options.NamedOvens || ForceRemoveAll) - New Appointments block (triggered by options.Appointments || ForceRemoveAll) - ResetDemoCompany: set ForceRemoveAll=true and enable all new flags so every re-seedable table is wiped clean before re-seeding Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
using PowderCoating.Core.Entities;
|
|
|
|
namespace PowderCoating.Application.Interfaces;
|
|
|
|
public interface ISeedDataService
|
|
{
|
|
/// <summary>
|
|
/// Seeds only lookup tables for a new company (called automatically on company creation).
|
|
/// This includes job statuses, priorities, and quote statuses.
|
|
/// </summary>
|
|
/// <param name="companyId">The company to seed lookup data for</param>
|
|
/// <returns>Result message indicating what was seeded</returns>
|
|
Task<SeedDataResult> SeedCompanyLookupsAsync(int companyId);
|
|
|
|
/// <summary>
|
|
/// Seeds initial data for a specific company
|
|
/// </summary>
|
|
/// <param name="companyId">The company to seed data for</param>
|
|
/// <returns>Result message indicating what was seeded</returns>
|
|
Task<SeedDataResult> SeedCompanyDataAsync(int companyId);
|
|
|
|
/// <summary>
|
|
/// Seeds system-level data (roles, default company, SuperAdmins)
|
|
/// </summary>
|
|
/// <returns>Result message indicating what was seeded</returns>
|
|
Task<SeedDataResult> SeedSystemDataAsync();
|
|
|
|
/// <summary>
|
|
/// Removes seeded demo data for a company based on the selected options.
|
|
/// Matches records by their known seed identifiers (emails, SKUs, serial numbers, etc.).
|
|
/// </summary>
|
|
Task<SeedDataResult> RemoveSeedDataAsync(int companyId, RemoveSeedDataOptions options);
|
|
|
|
/// <summary>
|
|
/// Gets a list of all companies for seeding
|
|
/// </summary>
|
|
Task<List<Company>> GetCompaniesAsync();
|
|
}
|
|
|
|
public class RemoveSeedDataOptions
|
|
{
|
|
public bool Customers { get; set; }
|
|
public bool InventoryItems { get; set; }
|
|
public bool Equipment { get; set; }
|
|
public bool Catalog { get; set; }
|
|
public bool PricingTiers { get; set; }
|
|
public bool OperatingCosts { get; set; }
|
|
public bool Bills { get; set; }
|
|
public bool Expenses { get; set; }
|
|
public bool Workers { get; set; }
|
|
public bool Vendors { get; set; }
|
|
public bool NamedOvens { get; set; }
|
|
public bool Appointments { get; set; }
|
|
|
|
/// <summary>
|
|
/// When true, all removal blocks skip fingerprint matching and delete by CompanyId only.
|
|
/// Use for demo resets where the goal is a full wipe regardless of which code version seeded
|
|
/// the data. Never set this on a real tenant company.
|
|
/// </summary>
|
|
public bool ForceRemoveAll { get; set; }
|
|
}
|
|
|
|
public class SeedDataResult
|
|
{
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; } = string.Empty;
|
|
public List<string> Details { get; set; } = new();
|
|
public List<string> Warnings { get; set; } = new();
|
|
public int ItemsSeeded { get; set; }
|
|
public int ItemsSkipped { get; set; }
|
|
}
|