Esempio n. 1
0
        public static async Task AddAuditedAsync <TEntity>(this BaseDbContext <AuditTrails, ExceptionLogs, UserBlobs> dbContext, IEnumerable <TEntity> entities, string transactionMessage, string createdBy = null, string controllerName = null, string actionName = null, string remoteIpAddress = null)
            where TEntity : class
        {
            await dbContext.AddRangeAsync(entities);

            await dbContext.AddRangeAsync(entities.CreateAuditTrails(transactionMessage, createdBy, controllerName, actionName, remoteIpAddress));
        }
Esempio n. 2
0
        public async Task <IEnumerable <WeatherForecast> > Get()
        {
            var list = await _dbContext.Set <WeatherForecast>().ToListAsync();

            if (list.Count == 0)
            {
                var rng = new Random();
                list = Enumerable.Range(1, 5).Select(index => new WeatherForecast
                {
                    Date         = DateTime.Now.AddDays(index),
                    TemperatureC = rng.Next(-20, 55),
                    Summary      = Summaries[rng.Next(Summaries.Length)]
                }).ToList();
                await _dbContext.AddRangeAsync(list);

                await _dbContext.SaveChangesAsync();
            }
            return(list);
        }
 public async Task AddRangeAsync(IList <TModel> modelsToAdd)
 {
     var entitiesToAdd = _iMapper.Map <TEntity>(modelsToAdd);
     await _baseDbContext.AddRangeAsync(entitiesToAdd);
 }