ef15fd6247
Full backend implementation: - Multi-tenant cafe/restaurant management (menus, orders, tables, staff) - POS order flow with ZarinPal and Snappfood payment integration - OTP authentication via Kavenegar SMS - QR digital menu with public discover/finder endpoints - Customer loyalty, coupons, CRM - PostgreSQL via EF Core, Redis for caching/sessions - Background jobs, webhook handlers - Full migration history Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Meezi.Core.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Meezi.Infrastructure.Data;
|
|
|
|
public static class DemoEmployeesSeeder
|
|
{
|
|
public static async Task EnsureEmployeesAsync(AppDbContext db, string cafeId, ILogger logger)
|
|
{
|
|
var existingPhones = await db.Employees
|
|
.Where(e => e.CafeId == cafeId && e.DeletedAt == null)
|
|
.Select(e => e.Phone)
|
|
.ToListAsync();
|
|
|
|
var added = 0;
|
|
foreach (var seed in DemoEmployeesCatalog.Employees)
|
|
{
|
|
if (existingPhones.Contains(seed.Phone))
|
|
continue;
|
|
|
|
if (await db.Employees.AnyAsync(e => e.Id == seed.Id, cancellationToken: default))
|
|
continue;
|
|
|
|
db.Employees.Add(new Employee
|
|
{
|
|
Id = seed.Id,
|
|
CafeId = cafeId,
|
|
BranchId = seed.BranchId,
|
|
Name = seed.Name,
|
|
Phone = seed.Phone,
|
|
Role = seed.Role,
|
|
BaseSalary = seed.BaseSalary
|
|
});
|
|
added++;
|
|
}
|
|
|
|
if (added > 0)
|
|
{
|
|
await db.SaveChangesAsync();
|
|
logger.LogInformation("Demo employees seed: {Count} added for cafe {CafeId}", added, cafeId);
|
|
}
|
|
}
|
|
}
|