Exemplo n.º 1
0
 public void SeedTestLocations(VHDbmodelContext ctx)
 {
     ctx.Location.Add(new Location()
     {
         Id     = 1,
         Name   = "Vacation Hire HQ",
         Adress = "Vacation way 1, AZ"
     });
     ctx.SaveChanges();
 }
Exemplo n.º 2
0
        public void SeedTestOrders(VHDbmodelContext ctx)
        {
            ctx.Order.Add(
                new Order()
            {
                AssetId    = 1,
                CustomerId = 1,
                From       = DateTimeOffset.Parse("2021-01-01"),
                To         = DateTimeOffset.Parse("2021-12-01"),
                Status     = OrderStatus.Active,
            });

            ctx.SaveChanges();
        }
Exemplo n.º 3
0
 public void SeedTestCustomers(VHDbmodelContext ctx)
 {
     ctx.Customer.Add(new Customer()
     {
         Name  = "Test User 1",
         Email = "*****@*****.**",
         Age   = 55,
     });
     ctx.Customer.Add(new Customer()
     {
         Name  = "Test User 2",
         Email = "*****@*****.**",
         Age   = 69,
     });
     ctx.SaveChanges();
 }
Exemplo n.º 4
0
 public void SeedTestAssets(VHDbmodelContext ctx)
 {
     ctx.Asset.Add(new Asset()
     {
         Id             = 1,
         Type           = "MotorVehicle",
         BasePrice      = 66,
         Identification = "VH1233",
     });
     ctx.Asset.Add(new Asset()
     {
         Id             = 2,
         Type           = "MotorVehicle",
         BasePrice      = 99,
         Identification = "MTZ-2231",
     });
     ctx.SaveChanges();
 }
Exemplo n.º 5
0
        public void SeedDatabase()
        {
            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();

            string basePath  = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"SeedData");
            string assetPath = Path.Combine(basePath, "asset-incomplete.json");
            string json      = System.IO.File.ReadAllText(assetPath);
            var    assets    = JsonConvert.DeserializeObject <List <Asset> >(json);

            _ctx.Asset.AddRange(assets);

            string customerPath = Path.Combine(basePath, "customer.json");

            json = System.IO.File.ReadAllText(customerPath);
            var customers = JsonConvert.DeserializeObject <List <Customer> >(json);

            _ctx.Customer.AddRange(customers);

            _ctx.SaveChanges();
        }