本文整理汇总了C#中TouchForFood.Models.touch_for_foodEntities类的典型用法代码示例。如果您正苦于以下问题:C# touch_for_foodEntities类的具体用法?C# touch_for_foodEntities怎么用?C# touch_for_foodEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
touch_for_foodEntities类属于TouchForFood.Models命名空间,在下文中一共展示了touch_for_foodEntities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteTest
public void DeleteTest()
{
//Arrange
db = new touch_for_foodEntities();
TableOM target = new TableOM(db);
int expected = 3;
int actual;
table t = db.tables.Find(table1.id);
//Check Setup
Assert.IsNotNull(db.tables.Find(table1.id));
Assert.IsNotNull(db.orders.Find(order1.id).table_id);
Assert.IsNotNull(db.service_request.Find(serviceRequest1.id).table_id);
//Act
actual = target.delete(table1.id);
//Assert
db = new touch_for_foodEntities();
Assert.IsNull(db.tables.Find(table1.id));
Assert.IsNull(db.orders.Find(order1.id).table_id);
Assert.IsNull(db.service_request.Find(serviceRequest1.id).table_id);
Assert.AreEqual(expected, actual);
}
示例2: getOpenOrder
/**
* Filters the categories and only returns those that are not already assigned to the menu
* that is passed in.
* */
public static order getOpenOrder(user usr)
{
touch_for_foodEntities db = new touch_for_foodEntities();
order o;
var models = db.orders
.Where(p => p.order_status == (int)OrderStatusHelper.OrderStatusEnum.PLACED || p.order_status == (int)OrderStatusHelper.OrderStatusEnum.EDITING || p.order_status == (int)OrderStatusHelper.OrderStatusEnum.PROCESSING)
.Where(p=>p.user_id == usr.id)
.OrderByDescending(p=>p.timestamp)
.ToList()
.Select(item =>
new order
{
id = item.id,
timestamp = item.timestamp,
total = item.total,
order_status = item.order_status,
order_item = item.order_item,
user = item.user,
table = item.table
}).AsQueryable();
if (models.Any())
{
o = models.ToArray()[0];
return o;
}
return null;
}
示例3: FilterListBySide
/**
* Filters the sides and only returns those that are not already assigned to the menu
* that is passed in.
* */
public static IList<side> FilterListBySide(menu_category menu_category)
{
touch_for_foodEntities db = new touch_for_foodEntities();
List<side> filteredList = new List<side>();
int resto_id = menu_category.menu.resto_id;
// We want all sides that do not exist in this menu_category and that belong to this restaurant.
// is_deleted and is_active need to be considered too. Show only sides where is_active is false
// if side is_deleted is true, then there should be another page to revert that. the side functionality
// I'm putting should only set a side to is_active is true or false
List<side> restaurantSides = db.sides.Where
(
si =>
si.menu_category.menu.resto_id == resto_id
&& si.is_active == false
&& si.is_deleted == false
).ToList();
foreach (var side in restaurantSides)
{
if (side.menu_category_id.Equals(menu_category.id))
{
filteredList.Add(side);
}
}
db.Dispose();
return filteredList;
}
示例4: 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();
}
示例5: CreatePartialTest
public void CreatePartialTest()
{
//Arrange
db = new touch_for_foodEntities();
PartialViewResult actual;
//Act
actual = (PartialViewResult)target.CreatePartial(menu1.id);
//Assert
Assert.AreEqual("_CategoryCreate", actual.ViewName);
}
示例6: 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();
}
示例7: getAuthenticatedUser
public static user getAuthenticatedUser(HttpContextBase httpContext)
{
try
{
db = new touch_for_foodEntities();
String username = httpContext.User.Identity.Name;
return db.users.FirstOrDefault(m => m.username.Equals(username, StringComparison.Ordinal));
}
catch (Exception)
{
return null;
}
}
示例8: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
//Add test data (order specific)
testDatabase = new TestDatabaseHelper();
restaurant1 = testDatabase.AddRestaurant();
table1 = testDatabase.AddTable(restaurant1);
user1 = testDatabase.AddUser("[email protected]", table1, (int)SiteRoles.Admin);
//Session
db = new touch_for_foodEntities();
target = new HomeController();
Session session = new Session(db, target);
session.simulateLogin(user1.username, user1.password);
}
示例9: AssignTest
public void AssignTest()
{
//Arrange
Util.Security.AES aes = new Util.Security.AES();
string encryption = aes.EncryptToString(table1.id.ToString());
//Act
RedirectToRouteResult actual = (RedirectToRouteResult)target.Assign(encryption);
//Assert
db = new touch_for_foodEntities();
Assert.AreEqual("Menu", actual.RouteValues["controller"]);
Assert.AreEqual("UserMenu", actual.RouteValues["action"]);
Assert.AreEqual(table1.id , db.users.Find(user1.id).current_table_id);
}
示例10: AddItem
/// <summary>
/// Creates an entry of type item in the database.
/// </summary>
/// <returns>The created item entry.</returns>
public item AddItem()
{
//Initialise
db = new touch_for_foodEntities();
item testItem = new item();
//Set Attributes
testItem.name = "UnitTest";
//Save
db.items.Add(testItem);
db.SaveChanges();
db.Dispose();
return testItem;
}
示例11: CancelConfirmedServiceRequestLockErrorTest
public void CancelConfirmedServiceRequestLockErrorTest()
{
//Check Setup
db = new touch_for_foodEntities();
Assert.IsTrue(db.service_request.Find(request1.id).status == (int)ServiceRequestUtil.ServiceRequestStatus.OPEN);
//Arrange
request1.version++;
//Act
target.CancelConfirmed(request1);
//Assert
db = new touch_for_foodEntities();
Assert.IsTrue(db.service_request.Find(request1.id).status == (int)ServiceRequestUtil.ServiceRequestStatus.OPEN);
}
示例12: 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));
}
示例13: 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;
}
示例14: 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;
}
示例15: CreateTest
public void CreateTest()
{
// Arrange
db = new touch_for_foodEntities();
RestaurantUserController target = new RestaurantUserController();
int numExpectedAssociations = db.restaurant_user.ToList<restaurant_user>().Count() + 1;
// Act
var actualResult = target.Create(restoUser2) as RedirectToRouteResult;
// Assertions
db = new touch_for_foodEntities();
var actualResultURI = actualResult.RouteValues["action"];
int actualRestoUsers = db.restaurant_user.ToList<restaurant_user>().Count();
Assert.AreEqual(numExpectedAssociations, actualRestoUsers);
Assert.AreEqual("Index", actualResultURI);
}