public static IEnumerable<Size> GetSizes(int colorId)
        {
            var hopeLingerieEntities = new HopeLingerieEntities();
            var sizes = new List<Size>();

            var nullSize = new Size();
            nullSize.Code = "-- Seleccionar --";
            nullSize.SizeId = 0;

            try
            {
                var color = hopeLingerieEntities.Colors.Single(x => x.ColorId == colorId && x.Active);
                sizes = color.Sizes.ToList();

                sizes.Insert(0, nullSize);
                return sizes;
            }
            catch
            {
                sizes.Insert(0, nullSize);
                return sizes;
            }
        }
        public ActionResult ComboSizePartialView()
        {
            var nullSize = new Size();
            nullSize.Code = "-- Seleccionar --";
            nullSize.SizeId = 0;

            var sizes = hopeLingerieEntities.Sizes.OrderBy(x => x.Code).Where(x => x.Active).ToList();
            sizes.Insert(0, nullSize);
            ViewData["Sizes"] = sizes;

            return PartialView();
        }
Esempio n. 3
0
        public virtual ActionResult ProductColorUpdate(int productId, int colorId)
        {
            Session["ColorID"] = colorId;
            ViewData["ProductId"] = productId;

            var nullSize = new HopeLingerieServices.Model.Size();
            nullSize.Code = "-- Seleccionar --";
            nullSize.SizeId = 0;

            var sizes = hopeLingerieEntities.Sizes.OrderBy(x => x.Code).Where(x => x.Active).ToList();
            sizes.Insert(0, nullSize);
            ViewData["Sizes"] = sizes;

            if (colorId > 0)
            {
                var color = hopeLingerieEntities.Colors.SingleOrDefault(a => a.ColorId == colorId && a.Active);

                ViewData["sizeList"] = hopeLingerieEntities.Stocks.Where(a => a.Active && a.ColorId == colorId && a.ProductId == productId).Select(x => new { ColorId = x.ColorId, ProductId = x.ProductId, SizeID = x.SizeId, Code = x.Size.Code, RealQuantity = x.RealQuantity, VirtualQuantity = x.VirtualQuantity, Description = x.Size.Description }).ToList();

                return View(color);
            }

            var newColor = new HopeLingerieServices.Model.Color();
            return View(newColor);
        }
Esempio n. 4
0
        public virtual ActionResult SizeUpdate(FormCollection formCollection)
        {
            HopeLingerieServices.Model.Size size = new HopeLingerieServices.Model.Size();

            if (Convert.ToInt16(formCollection["SizeId"]) > 0)
            {
                int sizeId = Convert.ToInt16(formCollection["SizeId"]);
                size = hopeLingerieEntities.Sizes.Single(x => x.SizeId == sizeId && x.Active);
            }

            TryUpdateModel(size, formCollection);

            if (size.SizeId <= 0)
            {
                hopeLingerieEntities.Sizes.AddObject(size);
            }

            hopeLingerieEntities.SaveChanges();

            return Redirect("/BackOffice/Sizes");
        }
 /// <summary>
 /// Create a new Size object.
 /// </summary>
 /// <param name="sizeId">Initial value of the SizeId property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 public static Size CreateSize(global::System.Int32 sizeId, global::System.String description, global::System.String code)
 {
     Size size = new Size();
     size.SizeId = sizeId;
     size.Description = description;
     size.Code = code;
     return size;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Sizes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSizes(Size size)
 {
     base.AddObject("Sizes", size);
 }