public void Waiter_Delete(Waiter item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         Waiter existing = context.Waiters.Find(item.WaiterID);
         context.Waiters.Remove(existing);
         context.SaveChanges();
     }
 }
 public void Waiter_Update(Waiter item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         context.Entry<Waiter>(context.Waiters.Attach(item)).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void Waiter_Add(Waiter item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         Waiter added = null;
         added = context.Waiters.Add(item);
         // commits the add to the database
         // evaluates the annotations (validations) on your entity
         // [Required],[StringLength],[Range],...
         context.SaveChanges();
     }
 }
Esempio n. 4
0
        public int Waiter_Add(Waiter item)
        {
            //input into this method is at the instance level
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //create a pointer variable for the instance type
                //set this pointer to null
                Waiter added = null;

                //set up the add request for the dbContext
                added = context.Waiters.Add(item);

                //Saving the changes will cause the .Add to execute
                //commits the add to the database
                //evaluates the annotations(validation) on your entity
                context.SaveChanges();

                return added.WaiterID;
            }
        }
Esempio n. 5
0
        public void Waiters_Delete(Waiter item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //look up the item instance on the database to determine if 
                //the instance exists
                //on the delete make sure you reference the PK field name
                Waiter existing = context.Waiters.Find(item.WaiterID);
                //setup the delete request command 
                context.Waiters.Remove(existing);
                //commit the action to happen
                context.SaveChanges();

            }
        }
        public void Waiter_Delete(Waiter item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //look th eitem instance on th edatabase to detemine if the insatnce exist
                //on the delete make sure u have PK name
                Waiter existing = context.Waiters.Find(item.WaiterID);

                //set up the data command request
                existing = context.Waiters.Remove(existing);

                //commit the action to happen
                context.SaveChanges();

            }
        }
Esempio n. 7
0
 public void Waiter_Add(Waiter item)
 {
     using(eRestaurantContext context = new eRestaurantContext())
     {
         Waiter added = null;
         added = context.Waiter.Add(item);
         context.SaveChanges();                                                  //Commits the add to the database.
                                                                                 //Furthermore, this evaluates the annotations (validates) on the entity.
                                                                                 //Included: [Required], [StringLength], [Range], etc.
     }
 }