Ejemplo n.º 1
0
        public ActionResult Index()
        {
            //Repositories.Repository <Models.Student> repo = new Repositories.Repository<Models.Student>();
            Repositories.BaseService<Models.Student> repo = new Repositories.BaseService<Models.Student>(new DAL.DatabaseContext());
            Models.Student stu = new Models.Student() { FirstMidName = "Lalo", LastName = "Landa", BirthDate = DateTime.Now };
            stu = repo.Find(x => x.ID.Equals(1));

            return View();
        }
Ejemplo n.º 2
0
        public double Checkout_Process(string input_string)
        {
            string item;
            int? quantity = 0;
            double? price = 0;

            //GROUP PRODUCTS
            IEnumerable<Product_Agrupation> g = Group_Products(input_string);

            //CALL REPOSITORY
            Repositories.BaseService<Models.Product> repo = new Repositories.BaseService<Models.Product>(new DAL.DatabaseContext());
            Models.Product prod = new Models.Product();

            foreach (var i in g)
            {
                //VARS
                item = i.Key.ToString();
                quantity = i.Count;

                //FIND PRODUCT
                try {
                    prod = repo.Find(x => x.item.Equals(item));
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                if (quantity > 0 && prod != null)
                {
                    //CHECK FOR OFFERS APPLICABILITY
                    if (prod.offer_quantity != null)
                    {
                        while (quantity >= prod.offer_quantity && prod.offer_quantity != 0)
                        {
                            price = price + prod.offer_price;
                            quantity = quantity - prod.offer_quantity;
                        }
                    }

                    //NORMAL PRICES
                    price = price + (quantity * prod.price);
                }
            }

            //FINALIZE
            repo = null;

            return price.Value;
        }