本文整理汇总了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类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:25,代码来源:TableOMTest.cs
示例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;
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:32,代码来源:SessionUtil.cs
示例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;
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:32,代码来源:SideUtil.cs
示例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();
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:8,代码来源:ReviewOMTest.cs
示例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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:12,代码来源:CategoryControllerTest.cs
示例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();
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:12,代码来源:ReviewOMTest.cs
示例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;
}
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:13,代码来源:UserUtil.cs
示例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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:14,代码来源:HomeControllerTest.cs
示例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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:15,代码来源:TableControllerTest.cs
示例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;
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:20,代码来源:TestDatabaseHelper.cs
示例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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:16,代码来源:ServiceRequestControllerTest.cs
示例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));
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:17,代码来源:MenuItemOMTest.cs
示例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;
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:23,代码来源:TestDatabaseHelper.cs
示例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;
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:21,代码来源:TestDatabaseHelper.cs
示例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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:17,代码来源:RestaurantUserControllerTest.cs
示例16: 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);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:19,代码来源:OrderOMTest.cs
示例17: GetAll
// Should be able to search:
// Item:
// - name, description, metadata
// Category:
// - name
// Menu:
// - name
public static IList<menu_item> GetAll(int restoId)
{
using (var db = new touch_for_foodEntities())
{
return db.menu_item
.Include(x => x.item)
.Include(x => x.menu_category.category)
.Include(x => x.menu_category.menu)
.Where
(
x => x.is_active == true &&
x.is_deleted == false &&
x.menu_category.is_active == true &&
x.menu_category.is_deleted == false &&
x.menu_category.menu.resto_id == restoId &&
x.menu_category.menu.is_active == true &&
x.menu_category.menu.is_deleted == false
).ToList();
}
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:27,代码来源:SearchService.cs
示例18: CreateUserDBEntityValidationExceptionTest
public void CreateUserDBEntityValidationExceptionTest()
{
//Arrange
db = new touch_for_foodEntities();
UserController target = new UserController();
user2.email = null;
user2.username = null;
int expectedUsers = db.users.ToList<user>().Count();
Session session = new Session(db, target);
var actual = target.Create(user2) as ViewResult;
// Assert
db = new touch_for_foodEntities();
int actualUsers = db.users.ToList<user>().Count();
string errorMsg = actual.ViewBag.Error;
Assert.IsNotNull(errorMsg); //error message is sent to view
Assert.AreEqual(expectedUsers, actualUsers);
Assert.AreEqual("Create", actual.ViewName); //Directed to correct location
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:20,代码来源:UserControllerTest.cs
示例19: CreateExceptionTest
public void CreateExceptionTest()
{
//Arrange
db = new touch_for_foodEntities();
target = new RestaurantController(); //reset target creating exception.
int numberOfRestaurantsBefore = db.restaurants.ToList<restaurant>().Count();
//Act
ViewResult actual = target.Create(restaurant2) as ViewResult;
//Assert
db = new touch_for_foodEntities();
int numberOfRestaurantsAfter = db.restaurants.ToList<restaurant>().Count();
List<restaurant_user> restaurantUsers = db.restaurant_user
.Where(ru => (ru.restaurant_id == restaurant2.id) &&
(ru.user_id == user1.id)).ToList<restaurant_user>();
string errorMsg = actual.ViewBag.Error;
Assert.AreEqual(numberOfRestaurantsBefore, numberOfRestaurantsAfter); //no restaurants are created
Assert.IsTrue(restaurantUsers.Count() == 0); //no restaurant_user are created
Assert.IsNotNull(errorMsg); //error message is sent to view
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:21,代码来源:RestaurantControllerTest.cs
示例20: 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.Customer);
order1 = testDatabase.AddOrder(table1);
item1 = testDatabase.AddItem();
category1 = testDatabase.AddCategory();
menu1 = testDatabase.AddMenu(restaurant1);
menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
orderItem1 = testDatabase.AddOrderItem(order1, menuItem1);
//Session
db = new touch_for_foodEntities();
ReviewController target = new ReviewController();
Session session = new Session(db, target);
session.simulateLogin(user1.username, user1.password);
}
开发者ID:pmoda,项目名称:TFFCode,代码行数:21,代码来源:ReviewControllerTest.cs
注:本文中的TouchForFood.Models.touch_for_foodEntities类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论