Example #1
0
        public async Task InsertSampleData(ConsignMaxDbContext db)
        {
            var states = GetStates();

            db.States.AddRange(states);
            try
            {
                int numAffected = await db.SaveChangesAsync();

                _Logger.LogInformation(@"Saved {numAffected} states");
            }
            catch (Exception exp)
            {
                _Logger.LogError($"Error in {nameof(ConsignMaxDbSeeder)}: " + exp.Message);
                throw;
            }

            var consignors = GetConsignors();

            db.Consignors.AddRange(consignors);
            try
            {
                int numAffected = await db.SaveChangesAsync();

                _Logger.LogInformation(@"Saved {numAffected} consignors");
            }
            catch (Exception exp)
            {
                _Logger.LogError($"Error in {nameof(ConsignMaxDbSeeder)}: " + exp.Message);
                throw;
            }
        }
Example #2
0
 public ConsignorsRepository(ConsignMaxDbContext context, ILoggerFactory loggerFactory)
 {
     _Context = context;
     _Logger  = loggerFactory.CreateLogger("ConsignorsRepository");
 }