Esempio n. 1
0
        public static async Task SeedAsync(LcpContext lcpContext, ILoggerFactory loggerFactory)
        {
            try
            {
                // Any checks for any records
                if (!lcpContext.Clients.Any())
                {
                    var clientsData = File.ReadAllText("../LCP.Infrastructure/SeedData/clients.json");
                    var clients     = JsonSerializer.Deserialize <List <Client> >(clientsData);

                    foreach (var client in clients)
                    {
                        lcpContext.Clients.Add(client);
                    }

                    await lcpContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                var logger = loggerFactory.CreateLogger <LcpContextSeed>();
                logger.LogError(ex.Message);
            }
        }
Esempio n. 2
0
 public ClientRepository(LcpContext lcpContext)
 {
     _lcpContext = lcpContext;
 }