本文整理汇总了C#中TouchForFood.Models.touch_for_foodEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# touch_for_foodEntities.SaveChanges方法的具体用法?C# touch_for_foodEntities.SaveChanges怎么用?C# touch_for_foodEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TouchForFood.Models.touch_for_foodEntities
的用法示例。
在下文中一共展示了touch_for_foodEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyClassCleanup
public static void MyClassCleanup()
{
touch_for_foodEntities db = new touch_for_foodEntities();
review r = db.reviews.Find(m_review.id);
db.reviews.Remove(r);
db.SaveChanges();
db.Dispose();
}
示例2: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
touch_for_foodEntities db = new touch_for_foodEntities();
m_review = new review();
m_review.restaurant_id = db.restaurants.First().id;
m_review.rating = 1;
m_review.is_anonymous = true;
db.reviews.Add(m_review);
db.SaveChanges();
db.Dispose();
}
示例3: AddFriendship
/// <summary>
/// Creates a friendship entity
/// </summary>
/// <param name="user1">The first user in the friendship</param>
/// <param name="user2">The second user in the friendship</param>
/// <returns>the created friendship entity</returns>
public friendship AddFriendship(user user1, user user2)
{
//Initialise
db = new touch_for_foodEntities();
friendship testFriendship = new friendship();
//Set Attributes
testFriendship.first_user = user1.id;
testFriendship.second_user = user2.id;
//Save
db.friendships.Add(testFriendship);
db.SaveChanges();
db.Dispose();
return testFriendship;
}
示例4: DeleteItemActiveExceptionTest
public void DeleteItemActiveExceptionTest()
{
//Arrange
db = new touch_for_foodEntities();
MenuItemOM target = new MenuItemOM(db);
menuItem1.is_active = true;
db.Entry(menuItem1).State = EntityState.Modified;
db.SaveChanges();
//Act
int actual = target.delete(menuItem1.id);
//Assert
db = new touch_for_foodEntities();
Assert.IsFalse(db.menu_item.Find(menuItem1.id).is_deleted);
Assert.IsNotNull(db.order_item.Find(orderItem1.id));
}
示例5: AddCategory
/// <summary>
/// Adds a category entry to the database
/// </summary>
/// <returns>The created category entity.</returns>
public category AddCategory()
{
//Initialise
db = new touch_for_foodEntities();
category testCategory = new category();
//Set attributes
testCategory.name = "UnitTest";
testCategory.version = 0;
//Save
db.categories.Add(testCategory);
db.SaveChanges();
db.Dispose();
return testCategory;
}
示例6: DeleteItemActiveExceptionTest
public void DeleteItemActiveExceptionTest()
{
//Arrange
db = new touch_for_foodEntities();
OrderOM target = new OrderOM(db);
orderItem1.order_item_status = (int)OrderStatusHelper.OrderItemStatusEnum.PROCESSING;
db.Entry(orderItem1).State = EntityState.Modified;
db.SaveChanges();
//Act
int actual = target.delete(order1.id);
//Assert
db = new touch_for_foodEntities();
Assert.IsFalse(db.orders.Find(order1.id).order_status ==
(int)OrderStatusHelper.OrderStatusEnum.DELETED);
Assert.IsFalse(db.order_item.Find(orderItem1.id).order_item_status ==
(int)OrderStatusHelper.OrderItemStatusEnum.DELETED);
}
示例7: DeleteConfirmedActiveExceptionTest
public void DeleteConfirmedActiveExceptionTest()
{
//Arrange
db = new touch_for_foodEntities();
item item1 = testDatabase.AddItem();
menu_item menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
//make menu active
menu1.is_active = true;
db.Entry(menu1).State = EntityState.Modified;
db.SaveChanges();
//Act
ActionResult actual = (ActionResult)target.DeleteConfirmed(menu1.id);
//Assert
db = new touch_for_foodEntities();
Assert.IsFalse(db.menus.Find(menu1.id).is_deleted);
Assert.IsFalse(db.menu_category.Find(menuCategory1.id).is_deleted);
Assert.IsFalse(db.menu_item.Find(menuItem1.id).is_deleted);
//Clean-up (order specific)
testDatabase.RemoveMenuItem(menuItem1);
testDatabase.RemoveItem(item1);
}
示例8: AddItem
/// <summary>
/// Creates an entry of type item in the database.
/// </summary>
/// <param name="catagoryEntity">Category that item is related to.</param>
/// <returns>The created item entry.</returns>
public item AddItem(category catagoryEntity)
{
//Initialise
db = new touch_for_foodEntities();
item testItem = new item();
//Set Attributes
testItem.name = "UnitTest";
testItem.category_id = catagoryEntity.id;
//Save
db.items.Add(testItem);
db.SaveChanges();
db.Dispose();
return testItem;
}
示例9: DeleteActiveMenuWarningTest
public void DeleteActiveMenuWarningTest()
{
//Arrange
db = new touch_for_foodEntities();
testDatabase.RemoveMenuCategory(menuCategory1);
menu1.is_active= true;
db.Entry(menu1).State = EntityState.Modified;
db.SaveChanges();
//Act
ViewResult actual = (ViewResult)target.Delete(menu1.id);
//Assert
string actualWarning = actual.ViewBag.Warning;
Assert.IsFalse(String.IsNullOrWhiteSpace(actualWarning));
menu actualMenu = (menu)actual.ViewData.Model;
Assert.AreEqual(actualMenu.id, menu1.id);
}
示例10: RemoveWaiter
/// <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();
}
示例11: AddBill
/// <summary>
/// Adds a bill entry to the database
/// </summary>
/// <param name="orderEntity">The associated order</param>
/// <returns>The created bill entity.</returns>
internal bill AddBill(order orderEntity)
{
//Initialise
db = new touch_for_foodEntities();
bill testBill = new bill();
//Set attributes
testBill.order_id = orderEntity.id;
testBill.is_deleted = false;
//Save
db.bills.Add(testBill);
db.SaveChanges();
db.Dispose();
return testBill;
}
示例12: RemoveMenuCategory
/// <summary>
/// Remove menu item from database.
/// </summary>
/// <param name="menuCategoryEntity">Menu Category item to be removed.</param>
public void RemoveMenuCategory(menu_category menuCategoryEntity)
{
db = new touch_for_foodEntities();
if (db.menu_category.Find(menuCategoryEntity.id) != null)
{
db.menu_category.Remove(db.menu_category.Find(menuCategoryEntity.id));
db.SaveChanges();
}
db.Dispose();
}
示例13: RemoveTable
/// <summary>
/// Removes a table item from the database.
/// </summary>
/// <param name="tableEntity">The table to be removed.</param>
public void RemoveTable(table tableEntity)
{
db = new touch_for_foodEntities();
if (db.tables.Find(tableEntity.id) != null)
{
db.tables.Remove(db.tables.Find(tableEntity.id));
db.SaveChanges();
}
db.Dispose();
}
示例14: DeleteConfirmedTest
public void DeleteConfirmedTest()
{
//Setup
db = new touch_for_foodEntities();
user1.current_table_id = null;
db.Entry(user1).State = EntityState.Modified;
db.SaveChanges();
//CheckSetup
Assert.IsFalse(db.restaurants.Find(restaurant1.id).is_deleted);
Assert.IsNotNull(db.tables.Find(table1.id));
Assert.IsNotNull(db.restaurant_user.Find(restaurantUser1.id).restaurant_id);
Assert.IsFalse(db.menus.Find(menu1.id).is_deleted);
Assert.IsNotNull(db.reviews.Find(review1.id));
//Act
var actual = target.DeleteConfirmed(restaurant1.id);
//Assert
db = new touch_for_foodEntities();
Assert.IsTrue(db.restaurants.Find(restaurant1.id).is_deleted);
Assert.IsNull(db.tables.Find(table1.id));
Assert.IsNull(db.restaurant_user.Find(restaurantUser1.id).restaurant_id);
Assert.IsTrue(db.menus.Find(menu1.id).is_deleted);
Assert.IsNull(db.reviews.Find(review1.id));
}
示例15: RemoveCategory
///<summary>
/// Removes a bill from the database.
/// </summary>
/// <param name="billEntity">Bill to be removed.</param>
public void RemoveCategory(category categoryEntity)
{
db = new touch_for_foodEntities();
if (db.categories.Find(categoryEntity.id) != null)
{
db.categories.Remove(db.categories.Find(categoryEntity.id));
db.SaveChanges();
}
db.Dispose();
}