using Indotalent.ConfigBackEnd.Extensions; using Indotalent.Data.Entities; using Microsoft.EntityFrameworkCore; namespace Indotalent.Infrastructure.Database.Demo; public static class VendorSeeder { public static async Task GenerateDataAsync(AppDbContext context) { if (await context.Vendor.AnyAsync()) return; var groups = await context.VendorGroup.Select(x => x.Id).ToArrayAsync(); var categories = await context.VendorCategory.Select(x => x.Id).ToArrayAsync(); var cities = new string[] { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix", "Philadelphia", "Miami", "San Francisco", "Seattle", "Austin" }; var streets = new string[] { "Medical Center Blvd", "Healthway Drive", "Innovation Road", "Science Park Ave", "Clinical Way", "Wellness Blvd", "Recovery Street", "Research Lane", "Care Avenue", "Pharma Street" }; var states = new string[] { "NY", "CA", "IL", "TX", "AZ", "PA", "FL", "GA", "WA", "MA" }; var zipCodes = new string[] { "10001", "90210", "60601", "77001", "85001", "19101", "33101", "94102", "98101", "73301" }; var phoneNumbers = new string[] { "212-555-0199", "310-555-0188", "312-555-0177", "713-555-0166", "602-555-0155", "305-555-0144" }; var emails = new string[] { "sales@med-supply.com", "info@pharmadistribution.net", "contact@healthequip.com", "support@biotechlabs.us", "wholesale@medinstruments.com" }; var random = new Random(); var entityName = nameof(Vendor); var vendors = new List { new Vendor { Name = "MediTech Solutions" }, new Vendor { Name = "Global Pharma Network" }, new Vendor { Name = "CarePlus Medical Supplies" }, new Vendor { Name = "Apex Health Instruments" }, new Vendor { Name = "LifeLine Diagnostic Labs" }, new Vendor { Name = "SterileMed Consumables" }, new Vendor { Name = "NovaCare Equipment" }, new Vendor { Name = "HealthGuard Systems" }, new Vendor { Name = "BioGenix Pharmaceuticals" }, new Vendor { Name = "Prime Medical Devices" }, new Vendor { Name = "VitalSign Technologies" }, new Vendor { Name = "Surgical Precision Inc." }, new Vendor { Name = "ClinicCore Furniture" }, new Vendor { Name = "MedTex Linens & Uniforms" }, new Vendor { Name = "Aura Medical Software" }, new Vendor { Name = "SafeWaste Management" }, new Vendor { Name = "ProHealth Dental Supplies" }, new Vendor { Name = "ClearView Radiology Tech" }, new Vendor { Name = "SanitizePro Chemicals" }, new Vendor { Name = "FirstAid Emergency Kits" } }; foreach (var vendor in vendors) { var autoNo = await context.GenerateAutoNumberAsync( entityName: entityName, prefixTemplate: $"{entityName.ToShortNameConsonant(3)}/{{Year}}/" ); vendor.AutoNumber = autoNo; vendor.VendorGroupId = GetRandomValue(groups, random); vendor.VendorCategoryId = GetRandomValue(categories, random); vendor.City = GetRandomString(cities, random); vendor.Street = GetRandomString(streets, random); vendor.State = GetRandomString(states, random); vendor.ZipCode = GetRandomString(zipCodes, random); vendor.PhoneNumber = GetRandomString(phoneNumbers, random); vendor.EmailAddress = GetRandomString(emails, random); await context.Vendor.AddAsync(vendor); } await context.SaveChangesAsync(); } private static T GetRandomValue(T[] array, Random random) { return array[random.Next(array.Length)]; } private static string GetRandomString(string[] array, Random random) { return array[random.Next(array.Length)]; } }