public ModelLibrary.Menu ConvertMenuToModel(DatabaseAccessLibrary.Menu dbMenu) { var modelMenu = new ModelLibrary.Menu(); List <ModelLibrary.Item> itemList = new List <ModelLibrary.Item>(); ItemCtrl itemCtrl = new ItemCtrl(); if (dbMenu == null) { return(modelMenu); } foreach (var Item in dbMenu.Items) { itemList.Add(itemCtrl.ConvertItemToModel(Item)); } if (itemList.Count > 0) { modelMenu.RestaurantId = dbMenu.restaurantId; modelMenu.Id = dbMenu.id; modelMenu.Name = dbMenu.name; modelMenu.Items = itemList; modelMenu.Active = dbMenu.active; return(modelMenu); } modelMenu.RestaurantId = dbMenu.restaurantId; modelMenu.Id = dbMenu.id; modelMenu.Name = dbMenu.name; modelMenu.Active = dbMenu.active; return(modelMenu); }
public ModelLibrary.ItemCat ConvertItemCatToModel(DatabaseAccessLibrary.ItemCat dbItemCat) { var modelItemCat = new ModelLibrary.ItemCat(); List <ModelLibrary.Item> itemList = new List <ModelLibrary.Item>(); ItemCtrl itemCtrl = new ItemCtrl(); if (dbItemCat == null) { return(modelItemCat); } foreach (var Item in dbItemCat.Items) { itemList.Add(itemCtrl.ConvertItemToModel(Item)); } if (itemList.Count > 0) { modelItemCat.Name = dbItemCat.name; modelItemCat.Id = dbItemCat.id; modelItemCat.Items = itemList; return(modelItemCat); } modelItemCat.Name = dbItemCat.name; modelItemCat.Id = dbItemCat.id; return(modelItemCat); }
public ModelLibrary.Menu GetActiveMenu(int restaurantId) { var menuDb = new MenuDb(); var itemCtrl = new ItemCtrl(); var menu = ConvertMenuToModel(menuDb.GetActiveMenu(restaurantId)); menu.Items = itemCtrl.GetMenuItems(menu.Id); return(menu); }
public ModelLibrary.Menu CreateMenu(ModelLibrary.Menu menu) { var dbMenu = new DatabaseAccessLibrary.Menu(); ItemCtrl itemCtrl = new ItemCtrl(); dbMenu.name = menu.Name; dbMenu.restaurantId = menu.RestaurantId; dbMenu.active = menu.Active; DatabaseAccessLibrary.MenuDb menuDb = new DatabaseAccessLibrary.MenuDb(); menuDb.AddMenu(dbMenu); return(menu); }
private List <ModelLibrary.OrderLineItem> ConvertOrderLineItemsToModel(IEnumerable <OrderLineItem> orderLineItems) { var itemCtrl = new ItemCtrl(); var itemsList = new List <ModelLibrary.OrderLineItem>(); foreach (var item in orderLineItems) { var orderItem = new ModelLibrary.OrderLineItem { LineItem = itemCtrl.ConvertItemToModel(item.Item), Quantity = item.quantity }; itemsList.Add(orderItem); } return(itemsList); }