public static AutorContext DataInMemory()
        {
            var options = new DbContextOptionsBuilder <AutorContext>()
                          .EnableSensitiveDataLogging()
                          .UseInMemoryDatabase(Guid
                                               .NewGuid().ToString()).Options;

            var context = new AutorContext(options);

            context.Autor.AddRange(new List <AutorModel>()
            {
                new AutorModel()
                {
                    Id = 1, Nome = "Erick Henrique de Oliveira"
                },
                new AutorModel()
                {
                    Id = 2, Nome = "Claudia Carvalho dos Santos"
                },
                new AutorModel()
                {
                    Id = 3, Nome = "Fatima dos Santos"
                },
            });

            context.SaveChanges();

            return(context);
        }
示例#2
0
        public AutorController(AutorContext context)
        {
            _context = context;

            if (_context.AutorItems.Count() == 0)
            {
                _context.SaveChanges();
            }
        }
        public static void Initialize(AutorContext context)
        {
            context.Database.EnsureCreated();

            if (context.Autor.Any())
            {
                return;
            }

            var autores = new AutorModel[]
            {
                new AutorModel {
                    Nome = "Erick de Oliveira"
                },
                new AutorModel {
                    Nome = "Erick de Oliveira Junior"
                },
                new AutorModel {
                    Nome = "Erick Filho"
                },
                new AutorModel {
                    Nome = "Claudia Carvalho"
                },
                new AutorModel {
                    Nome = "Antonio dos Santos"
                },
                new AutorModel {
                    Nome = "Antonio"
                },
                new AutorModel {
                    Nome = "Antonio Andrade"
                },
            };

            foreach (AutorModel autor in autores)
            {
                context.Autor.Add(autor);
            }

            context.SaveChanges();
        }
示例#4
0
 public AutorController(AutorContext context)
 {
     _context = context;
 }
示例#5
0
 public NewAutorCommandHandler(AutorContext context)
 {
     _context = context;
 }
示例#6
0
 public GetAutorQueryHandler(AutorContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }