Files
meezi/src/Meezi.Infrastructure/Data/DemoCouponSeeder.cs
T
soroush.asadi ef15fd6247 feat(api): .NET 10 multi-tenant REST API
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>
2026-05-27 21:33:48 +03:30

44 lines
1.3 KiB
C#

using Meezi.Core.Entities;
using Meezi.Core.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace Meezi.Infrastructure.Data;
public static class DemoCouponSeeder
{
public static async Task EnsureCouponsAsync(AppDbContext db, string cafeId, ILogger logger)
{
if (await db.Coupons.AnyAsync(c => c.CafeId == cafeId && c.Code == "WELCOME10"))
return;
db.Coupons.AddRange(
new Coupon
{
Id = "coupon_demo_welcome10",
CafeId = cafeId,
Code = "WELCOME10",
Type = CouponType.Percentage,
Value = 10,
MaxDiscount = 50_000,
MinOrderAmount = 100_000,
UsageLimit = 100,
IsActive = true
},
new Coupon
{
Id = "coupon_demo_save20k",
CafeId = cafeId,
Code = "SAVE20",
Type = CouponType.FixedAmount,
Value = 20_000,
MinOrderAmount = 150_000,
UsageLimit = 50,
IsActive = true
});
await db.SaveChangesAsync();
logger.LogInformation("Demo coupons seeded: WELCOME10, SAVE20 for cafe {CafeId}", cafeId);
}
}