public void Delete(restaurant toDelete)
 {
     if (toDelete == null)
     {
         throw new ArgumentNullException("toDelete");
     }
     db.restaurants.Remove(toDelete);
     db.SaveChanges();
 }
 public void Create(restaurant toInsert)
 {
     if (toInsert == null)
     {
         throw new ArgumentNullException("toInsert");
     }
     db.restaurants.Add(toInsert);
     db.SaveChanges();
 }
        public void Update(restaurant updateFrom)
        {
            if (updateFrom == null)
            {
                throw new ArgumentNullException("toUpdate");
            }
            restaurant toUpdate = GetRestaurantById(updateFrom.id);

            toUpdate.name        = updateFrom.name;
            toUpdate.phoneNumber = updateFrom.phoneNumber;
            toUpdate.address     = updateFrom.address;
            db.SaveChanges();
        }
        public restaurant GetRestaurantById(int id)
        {
            restaurant toFind = null;

            foreach (restaurant currentRest in db.restaurants)
            {
                if (currentRest.id == id)
                {
                    toFind = currentRest;
                    break;
                }
            }
            return(toFind);
        }