예제 #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;
            }
        }
예제 #2
0
        public async Task <Consignor> InsertConsignorAsync(Consignor Consignor)
        {
            _Context.Add(Consignor);
            try
            {
                await _Context.SaveChangesAsync();
            }
            catch (System.Exception exp)
            {
                _Logger.LogError($"Error in {nameof(InsertConsignorAsync)}: " + exp.Message);
            }

            return(Consignor);
        }