/// <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(); }
/// <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; }
/// <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); }
/// <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; }
public void MyTestInitialize() { //Add test data (order specific) restaurant1 = testDatabase.AddRestaurant(); table1 = testDatabase.AddTable(restaurant1); waiter1 = testDatabase.AddWaiter(restaurant1); order1 = testDatabase.AddOrder(table1, waiter1); }