Exemplo n.º 1
0
 // The Id will be set to the Identity column
 // Framework will add the id value into the restaurant
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant);
     // changes don't occur until you save
     _context.SaveChanges();
     return(restaurant);
 }
Exemplo n.º 2
0
        public Restaurant Add(Restaurant newRestaurant)
        {
            _context.Add(newRestaurant);
            _context.SaveChanges();

            return(newRestaurant);
        }
Exemplo n.º 3
0
        /* Restaurant */

        public Restaurant Add(Restaurant newRestaurant)
        {
            _context.Restaurants.Add(newRestaurant); // A brand new entity that we need to insert.
            _context.SaveChanges();                  // Changes dont occur until this command is called. May want to have this in a diff method called SaveChanges, or Commit, or something because we may want to batch together multiple changes on a single transaction.

            return(newRestaurant);
        }
Exemplo n.º 4
0
        public Restaurant Add(Restaurant restaurant)
        {
            _context.Restaurants.Add(restaurant);
            _context.SaveChanges();

            return(restaurant);
        }
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant);
     //simple approach, the savechanges can be moved out
     _context.SaveChanges();
     return(restaurant);
 }
Exemplo n.º 6
0
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant);
     //TODO: unit of work
     _context.SaveChanges();
     return(restaurant);
 }
Exemplo n.º 7
0
 public Restaurant Add(Restaurant newRestaurant)
 {
     _context.Restaurants.Add(newRestaurant);
     _context.SaveChanges(); //data doesn't actually get modified in the DB until you run SaveChanges();
     //generally you won't do this immediately. usually you'd want to put it in another method on the interface that will allow you to batch all your changes in a transaction
     //when save is complete, any new records will automatically have IDs added by entity framework by assuming that any IDs are identities which means the ID is auto-generated by SQL Server
     return(newRestaurant);
 }
Exemplo n.º 8
0
        public Restaurant Add(Restaurant restaurant)
        {
            _context.Add(restaurant);

            // You can save changes later in big projects as a method called Commit or whatever
            _context.SaveChanges();
            return(restaurant);
        }
Exemplo n.º 9
0
 public Restaurant Add(Restaurant restaurant)
 {
     //put on hold to add
     _context.Restaurants.Add(restaurant);
     //actually add it
     _context.SaveChanges();
     return(restaurant);
 }
Exemplo n.º 10
0
        public Restaurant Add(Restaurant restaurant)
        {
            _context.Restaurants.Add(restaurant);

            //just for ease, but it needs to go in a special method for actual application perspectives
            _context.SaveChanges();

            return(restaurant);
        }
Exemplo n.º 11
0
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant);
     //dont need to call SaveChanges if we need to batch
     _context.SaveChanges();
     return(restaurant);
 }
        public Restaurant Add(Restaurant newRestaurant)
        {
            _context.Restaurants.Add(newRestaurant);
            _context.SaveChanges();

            // return same value that was passed in, but with id value populated
            return(newRestaurant);
        }
Exemplo n.º 13
0
 public Restaurant Add(Restaurant newRestaurant)
 {
     _context.Add(newRestaurant);
     ///may not want SaveChnages() to be here, want to make sure all changes are ready to be saved
     ///may
     _context.SaveChanges();
     return(newRestaurant);
 }
Exemplo n.º 14
0
 public void Add(Restaurant restaurant)
 {
     _context.Add(restaurant);
     _context.SaveChanges();
 }
Exemplo n.º 15
0
 public Restaurant Add(Restaurant restorantToAdd)
 {
     _restaurantsData.Restaurants.Add(restorantToAdd);
     _restaurantsData.SaveChanges();
     return(restorantToAdd);
 }
Exemplo n.º 16
0
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant);
     _context.SaveChanges(); // Better method use this in another method, you might save changes after multiple changes
     return(restaurant);     // new id property will be generated by sql
 }
Exemplo n.º 17
0
 public int Commit()
 {
     return(_odeToFoodDbContext.SaveChanges());
 }
Exemplo n.º 18
0
 public int Commit()
 {
     // TODO: Use async version.
     return(context.SaveChanges());
 }
Exemplo n.º 19
0
 public Restaurant Add(Restaurant restaurant)
 {
     _context.Restaurants.Add(restaurant); // creates the id column in database server
     _context.SaveChanges();
     return(restaurant);                   // the created id column is passed on to the object
 }
Exemplo n.º 20
0
 public void AddToInventory(Product prod)
 {
     _context.Products.Add(prod);
     _context.SaveChanges();
 }
Exemplo n.º 21
0
 public FoodContact Add(FoodContact foodContact)
 {
     _context.Add(foodContact);
     _context.SaveChanges();
     return(foodContact);
 }
Exemplo n.º 22
0
 public Restaurant Add(Restaurant newRestaurant)
 {
     _odeToFoodDbContext.Restaurants.Add(newRestaurant);
     _odeToFoodDbContext.SaveChanges();
     return(newRestaurant);
 }
Exemplo n.º 23
0
 public Restaurante Add(Restaurante restaurante)
 {
     _context.Restaurantes.Add(restaurante);
     _context.SaveChanges();
     return(restaurante);
 }
Exemplo n.º 24
0
 public int Commit()
 {
     return(_context.SaveChanges());
 }
Exemplo n.º 25
0
 public void SaveChanges()
 {
     context.SaveChanges();
 }
Exemplo n.º 26
0
 public void Commit()
 {
     _context.SaveChanges();
 }
Exemplo n.º 27
0
 public void Add(Restaurant restaurant)
 {
     db.Restaurants.Add(restaurant); // add to Restaurants table in 'db' database
     db.SaveChanges();               // save changes made in Restaurants table
 }