Esempio n. 1
0
        /// <summary>
        /// Deletes product
        /// </summary>
        /// <param name="product">product</param>
        /// <returns>true if successfully deleted</returns>
        public bool DeleteProduct <T>(T product)
        {
            bool deleted = false;

            switch (typeof(T).Name.ToString())
            {
            case "AlcoholDrink":
            {
                var mapper2 = new ReflectionBasedMapper <AlcoholDrinkDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "Burger":
            {
                var mapper2 = new ReflectionBasedMapper <BurgerDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "Drink":
            {
                var mapper2 = new ReflectionBasedMapper <DrinkDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "HotMeal":
            {
                var mapper2 = new ReflectionBasedMapper <HotMealDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "Pizza":
            {
                var mapper2 = new ReflectionBasedMapper <PizzaDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "Salad":
            {
                var mapper2 = new ReflectionBasedMapper <SaladDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }

            case "Soup":
            {
                var mapper2 = new ReflectionBasedMapper <SoupDAL, T>();
                deleted = dal.DeleteProduct(mapper2.MapBack(product));
                break;
            }
            }
            return(deleted);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates Product Repository
 /// </summary>
 public ProductRepository()
 {
     this.dal    = new DAL();
     this.mapper = new ReflectionBasedMapper <ProductBL, ProductDAL>();
 }
Esempio n. 3
0
        /// <summary>
        /// Static method Returns all Ts
        /// </summary>
        /// <returns>products</returns>
        public IEnumerable <T> GetAll <T>()
        {
            List <T> products = new List <T>();

            switch (typeof(T).Name.ToString())
            {
            case "AlcoholDrink":
                foreach (var item in dal.GetAll <AlcoholDrinkDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <AlcoholDrinkDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "Burger":
                foreach (var item in dal.GetAll <BurgerDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <BurgerDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "Drink":
                foreach (var item in dal.GetAll <DrinkDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <DrinkDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "HotMeal":
                foreach (var item in dal.GetAll <HotMealDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <HotMealDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "Pizza":
                foreach (var item in dal.GetAll <PizzaDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <PizzaDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "Salad":
                foreach (var item in dal.GetAll <SaladDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <SaladDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;

            case "Soup":
                foreach (var item in dal.GetAll <SoupDAL>())
                {
                    var mapper2 = new ReflectionBasedMapper <SoupDAL, T>();
                    products.Add(mapper2.Map(item));
                }
                break;
            }
            return(products);
        }