예제 #1
0
        public virtual ActionResult ProductColorUpdate(int colorId, FormCollection formCollection)
        {
            var color = hopeLingerieEntities.Colors.SingleOrDefault(a => a.ColorId == colorId && a.Active);
            bool isNew = false;

            if (color == null)
            {
                isNew = true;
                color = new HopeLingerieServices.Model.Color();
            }

            TryUpdateModel(color, formCollection);

            color.Description = formCollection["Descript"];

            if (isNew)
            {
                hopeLingerieEntities.Colors.AddObject(color);
            }

            hopeLingerieEntities.SaveChanges();

            return RedirectToAction("ProductUpdate", new { Id = color.ProductId });
        }
예제 #2
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);
        }