Esempio n. 1
0
        public IEnumerable <ModelLibrary.Item> GetCatItems(int itemCatId)
        {
            var itemDb    = new ItemDb();
            var priceCtrl = new PriceCtrl();

            var itemsDb = itemDb.GetCategoryItems(itemCatId);
            var items   = new List <ModelLibrary.Item>();

            foreach (var item in itemsDb)
            {
                var itemo = ConvertItemToModel(item);
                itemo.Price = priceCtrl.GetLatestPriceById(item.id);
                if (itemo.Price != null)
                {
                    items.Add(itemo);
                }
            }

            return(items);
        }
Esempio n. 2
0
        public IEnumerable <ModelLibrary.Item> GetMenuItems(int menuId)
        {
            var itemDb    = new ItemDb();
            var priceCtrl = new PriceCtrl();

            var itemsDb = itemDb.GetMenuItems(menuId);
            var items   = new List <ModelLibrary.Item>();

            foreach (var item in itemsDb)
            {
                var itemi = ConvertItemToModel(item);
                itemi.Price = priceCtrl.GetPriceItemId(item.id);
                if (itemi.Price != null)
                {
                    items.Add(itemi);
                }
            }

            return(items);
        }
Esempio n. 3
0
        public ModelLibrary.Item ConvertItemToModel(DatabaseAccessLibrary.Item dbItem)
        {
            var db        = new JustFeastDbDataContext();
            var priceCtrl = new PriceCtrl();
            var price     = db.Prices.Where(p => p.itemId == dbItem.id).OrderByDescending(p => p.startDate).FirstOrDefault();

            if (dbItem != null && price != null)
            {
                var modelItem = new ModelLibrary.Item
                {
                    Id          = dbItem.id,
                    Name        = dbItem.name,
                    Description = dbItem.description,
                    Price       = priceCtrl.ConvertPriceToModel(price)
                };
                return(modelItem);
            }
            else
            {
                return(null);
            }
        }