public static void Initialise(IServiceProvider serviceProvider)
        {
            using (var context = new LaptopDbContext(serviceProvider.GetRequiredService <DbContextOptions <LaptopDbContext> >()))
            {
                if (context.Laptops.Any())
                {
                    return;
                }
                else
                {
                    context.Laptops.AddRange(
                        new Laptop
                    {
                        Id    = new Guid("9ba0aea2-ec32-4cc9-90a3-a2f70895fdaf"),
                        Name  = "Dell",
                        Price = 349.87M
                    },
                        new Laptop
                    {
                        Id    = new Guid("ab147a3e-f10f-4be5-a403-b22202aa663b"),
                        Name  = "Toshiba",
                        Price = 345.67M
                    },
                        new Laptop
                    {
                        Id    = new Guid("d55588ad-52b5-4a36-a071-903be399d62d"),
                        Name  = "HP",
                        Price = 456.76M
                    }
                        );
                }

                context.SaveChanges();
            }
        }
Beispiel #2
0
 public ConfigurationService(LaptopDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Beispiel #3
0
 public GenericRepository(LaptopDbContext context)
 {
     _context = context;
 }
Beispiel #4
0
 public BaseDaoImp()
 {
     this.context = DataBaseFactory.context;
 }
Beispiel #5
0
 public LaptopDbContext Init()
 {
     return(dbContext ?? (dbContext = new LaptopDbContext()));
 }
 public CategoryController(LaptopDbContext dbContext)
 {
     context = dbContext;
 }
Beispiel #7
0
 public LaptopRepository(LaptopDbContext context) : base(context)
 {
     _context = context;
 }
Beispiel #8
0
 public LaptopController(LaptopDbContext dbContext)
 {
     context = dbContext;
 }
Beispiel #9
0
 public WishListController(LaptopDbContext dbContext)
 {
     context = dbContext;
 }
Beispiel #10
0
 public AuthRepository(LaptopDbContext context)
 {
     _context = context;
 }