public ActionResult Create([Bind(Include = "Id,Name,Weight,Lenght,Width,Height")] CartonBox cartonBox)
        {
            if (ModelState.IsValid)
            {
                List <PalletizationPicture> palletizationPictureList = new List <PalletizationPicture>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];
                    if (file != null && file.ContentLength > 0)
                    {
                        var filename = Path.GetFileName(file.FileName);
                        PalletizationPicture PalletizationPicture = new PalletizationPicture()
                        {
                            PictureName = filename,
                            Extension   = Path.GetExtension(filename),
                            //Guid = Guid.NewGuid()
                        };


                        palletizationPictureList.Add(PalletizationPicture);
                        var path = Path.Combine(Server.MapPath("~/Images/PalletizationPictures"), PalletizationPicture.PictureName);
                        file.SaveAs(path);
                    }
                }
                cartonBox.PalletizationPictures = palletizationPictureList;

                db.CartonBoxes.Add(cartonBox);
                db.SaveChanges();
                return(RedirectToAction("All"));
            }

            return(View(cartonBox));
        }
        public ActionResult Edit([Bind(Include = "CartonBoxId,Name,Weight,Lenght,Width,Height")] CartonBox cartonBoxInput)
        {
            if (ModelState.IsValid)
            {
                List <PalletizationPicture> palletizationPictureList = new List <PalletizationPicture>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];
                    if (file != null && file.ContentLength > 0)
                    {
                        var filename = Path.GetFileName(file.FileName);
                        PalletizationPicture PalletizationPicture = new PalletizationPicture()
                        {
                            PictureName = filename,
                            Extension   = Path.GetExtension(filename),
                        };


                        palletizationPictureList.Add(PalletizationPicture);
                        var path = Path.Combine(Server.MapPath("~/Images/PalletizationPictures"), PalletizationPicture.PictureName);
                        file.SaveAs(path);
                    }
                }

                var cartonBoxFromDB = db.CartonBoxes.Find(cartonBoxInput.CartonBoxId);

                cartonBoxFromDB.PalletizationPictures.Clear();
                cartonBoxFromDB.PalletizationPictures = palletizationPictureList;
                cartonBoxFromDB.Name   = cartonBoxInput.Name;
                cartonBoxFromDB.Weight = cartonBoxInput.Weight;
                cartonBoxFromDB.Lenght = cartonBoxInput.Lenght;
                cartonBoxFromDB.Width  = cartonBoxInput.Width;
                cartonBoxFromDB.Height = cartonBoxInput.Height;

                db.SaveChanges();
                return(RedirectToAction("All"));
            }
            return(View(cartonBoxInput));
        }