/*-------------------CASCADING COMBOS --------------------------*/
        public ActionResult MultiColumnProductComboBoxPartialView()
        {
            ViewData["Products"] = hopeLingerieEntities.Products.Where(a => a.Active).OrderBy(a => a.ProductId).ToList();

            var nullProduct = new Product();
            nullProduct.Code = "-- Seleccionar --";
            nullProduct.ProductId= 0;

            ((List<Product>)ViewData["Products"]).Insert(0, nullProduct);

            return PartialView();
        }
        public virtual ActionResult ProductUpdate(int Id, FormCollection formCollection)
        {
            var product = hopeLingerieEntities.Products.SingleOrDefault(a => a.ProductId == Id && a.Active);
            bool isNew = false;

            if (product == null)
            {
                isNew = true;
                product = new Product();
            }

            TryUpdateModel(product, formCollection);
            product.Description = formCollection["Descript"];
            product.IsNew = (formCollection["IsNew"] != "U");
            product.OnSale= (formCollection["OnSale"] != "U");
            product.CurrentPrice = Convert.ToDecimal(formCollection["CurrentPrice_Raw"]);
            if(!string.IsNullOrEmpty(formCollection["OldPrice_Raw"]))
                product.OldPrice = Convert.ToDecimal(formCollection["OldPrice_Raw"]);

            // Valida código no repetido
            if (isNew)
            {
                bool exists = (hopeLingerieEntities.Products.SingleOrDefault(a => a.Code == product.Code && a.Active) != null);

                if (exists) return RedirectToAction("Products");

                hopeLingerieEntities.Products.AddObject(product);
            }
            else
            {
                bool exists = (hopeLingerieEntities.Products.SingleOrDefault(a => a.Code == product.Code && a.ProductId != Id && a.Active) != null);

                if (exists) return RedirectToAction("Products");
            }

            hopeLingerieEntities.SaveChanges();

            TempData["Legend"] = "Producto actualizado correctamente!";

            return RedirectToAction("ProductUpdate", new { Id = product.ProductId });
        }
        public virtual ActionResult ProductUpdate(int Id)
        {
            ViewData["Categories"] = hopeLingerieEntities.Categories.OrderBy(x => x.Description).Where(x => x.Active && x.ParentCategoryId == null).ToList();

            if (Id > 0)
            {
                var product = hopeLingerieEntities.Products.SingleOrDefault(a => a.ProductId == Id && a.Active);

                ViewData["ProductId"] = Id;
                return View(product);
            }

            var newProduct = new Product();
            return View(newProduct);
        }
        public virtual ActionResult OrderUpdate(int Id)
        {
            ViewData["OrderStatus"] = hopeLingerieEntities.OrderStatus1.OrderBy(x => x.Description).Where(x => x.Active).ToList();
            ViewData["Products"] = hopeLingerieEntities.Products.OrderBy(x => x.ProductId).ToList();

            var nullProduct = new Product();
            nullProduct.Code = "-- Seleccionar --";
            nullProduct.ProductId = 0;

            ((List<Product>)ViewData["Products"]).Insert(0, nullProduct);

            if (Id > 0)
            {
                var order = hopeLingerieEntities.Orders.SingleOrDefault(a => a.OrderId == Id && a.Active);

                Session["OrderID"] = order.OrderId;

                if (order.CouponId.HasValue)
                {
                    var coupon = hopeLingerieEntities.Coupons.SingleOrDefault(x => x.CouponId == order.CouponId);
                    ViewData["Coupon"] = coupon.Code;
                }
                else
                    ViewData["Coupon"] = string.Empty;

                ViewData["Discount"] = Convert.ToDecimal(order.Discount) / 100;
                return View(order);
            }

            var newCustomer = new Customer();
            var newOrder = new Order();
            newOrder.OrderStatusId = 1;
            newOrder.Customer = newCustomer;

            return View(newOrder);
        }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="categoryId">Initial value of the CategoryId property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="currentPrice">Initial value of the CurrentPrice property.</param>
 /// <param name="published">Initial value of the Published property.</param>
 public static Product CreateProduct(global::System.Int32 productId, global::System.Int32 categoryId, global::System.String code, global::System.String name, global::System.Decimal currentPrice, global::System.Boolean published)
 {
     Product product = new Product();
     product.ProductId = productId;
     product.CategoryId = categoryId;
     product.Code = code;
     product.Name = name;
     product.CurrentPrice = currentPrice;
     product.Published = published;
     return product;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }