예제 #1
0
 public Model.Location AddLocation(Model.Location location)
 {
     _context.Locations.Add(
         new Entity.Location
     {
         Name    = location.Name,
         Address = location.Address
     }
         );
     _context.SaveChanges();
     return(location);
 }
예제 #2
0
 public Model.Customer AddCustomer(Model.Customer newCustomer)
 {
     _context.Customers.Add(_mapper.ParseCustomer(newCustomer));
     _context.SaveChanges();
     return(newCustomer);
 }
예제 #3
0
        public void Seed()
        {
            using (var context = new Entity.StoreAppDBContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                context.Customers.AddRange
                (
                    new Entity.Customer
                {
                    Id          = 1,
                    LastName    = "Yang",
                    MiddleName  = "",
                    FirstName   = "Jessie",
                    PhoneNumber = "2067798888"
                },
                    new Entity.Customer
                {
                    Id          = 2,
                    LastName    = "Fang",
                    MiddleName  = "W",
                    FirstName   = "Jia",
                    PhoneNumber = "2063317069"
                }
                );

                context.Products.AddRange(
                    new Entity.Product
                {
                    Id      = 1,
                    Name    = "Jasmine Green Tea w/ Salted Cheese",
                    Price   = 4.50m,
                    Barcode = "j-g-t-s-01"
                },
                    new Entity.Product
                {
                    Id      = 2,
                    Name    = "Classic Milk Tea",
                    Price   = 3.99m,
                    Barcode = "c-m-t-01"
                }
                    );

                context.Locations.AddRange(
                    new Entity.Location
                {
                    Id      = 1,
                    Name    = "WA-Seattle",
                    Address = "2245 8th Ave., R1-1A Seattle WA 98121"
                }
                    );

                context.Inventories.AddRange(
                    new Entity.Inventory
                {
                    Id         = 1,
                    LocationId = 1,
                    ProductId  = 1,
                    Quantity   = 2
                }
                    );


                context.SaveChanges();
            }
        }