Esempio n. 1
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);
            }
        }