예제 #1
0
 /// <summary>
 /// Removes a waiter item from the database.
 /// </summary>
 /// <param name="waiterEntity">The waiter to be removed</param>
 public void RemoveWaiter(waiter waiterEntity)
 {
     db = new touch_for_foodEntities();
     if (db.waiters.Find(waiterEntity.id) != null)
     {
         db.waiters.Remove(db.waiters.Find(waiterEntity.id));
         db.SaveChanges();
     }
     db.Dispose();
 }
예제 #2
0
        /// <summary>
        /// Creates a waiter entity
        /// </summary>
        /// <param name="restaurantEntity">Associated restaurant</param>
        /// <returns>Created restaurant entity</returns>
        public waiter AddWaiter(restaurant restaurantEntity)
        {
            //Initialise
            db = new touch_for_foodEntities();
            waiter testWaiter = new waiter();

            //Set attributes
            testWaiter.first_name = "UnitTest";
            testWaiter.last_name = "UnitTest";
            testWaiter.version = 1;
            testWaiter.resto_id = restaurantEntity.id;

            //Save
            db.waiters.Add(testWaiter);
            db.SaveChanges();
            db.Dispose();

            return testWaiter;
        }
예제 #3
0
파일: WaiterOM.cs 프로젝트: pmoda/TFFCode
 /// <summary>
 /// Writes a waiter object to the database
 /// </summary>
 /// <param name="waiter">The waiter object to write</param>
 /// <returns>True if successful, false otherwise</returns>
 public bool Create(waiter waiter)
 {
     db.waiters.Add(waiter);
     return (db.SaveChanges() == 1);
 }
예제 #4
0
        /// <summary>
        /// Creates an entry of type order in the database.
        /// </summary>
        /// <param name="orderTable">The table where orders are made from.</param>
        /// <param name="orderWaiter">The waiter in charge of order.</param>
        /// <returns>The created order entry.</returns>
        public order AddOrder(table orderTable, waiter orderWaiter)
        {
            //Initialise
            db = new touch_for_foodEntities();
            order testOrder = new order();

            //Set Attributes
            testOrder.timestamp = DateTime.Now;
            testOrder.table_id = orderTable.id;
            testOrder.waiter_id = orderWaiter.id;
            testOrder.version = 1;

            //Save
            db.orders.Add(testOrder);
            db.SaveChanges();
            db.Dispose();

            return testOrder;
        }
예제 #5
0
 public void MyTestInitialize()
 {
     //Add test data (order specific)
     restaurant1 = testDatabase.AddRestaurant();
     table1 = testDatabase.AddTable(restaurant1);
     waiter1 = testDatabase.AddWaiter(restaurant1);
     order1 = testDatabase.AddOrder(table1, waiter1);
 }