Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }