public ActionResult AddProduct(ProductRegister product, HttpPostedFileBase image1, HttpPostedFileBase image2, HttpPostedFileBase image3) { if (Request.Cookies["registered"] == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { string ownerid = Request.Cookies["registered"]["UserName"]; Product p = new Product { OwnerId = ur.FindOwnerId(ownerid), Date = DateTime.Now, ShortDescription = product.ShortDescription, LongDescription = product.LongDescription, Price = product.Price, Title = product.Title, State = Product.state.valid }; if (image1 != null) { p.Picture1 = new byte[image1.ContentLength]; image1.InputStream.Read(p.Picture1, 0, image1.ContentLength); } if (image2 != null) { p.Picture2 = new byte[image2.ContentLength]; image1.InputStream.Read(p.Picture2, 0, image2.ContentLength); } if (image3 != null) { p.Picture3 = new byte[image3.ContentLength]; image1.InputStream.Read(p.Picture3, 0, image3.ContentLength); } pr.AddProductToDb(p); return(RedirectToAction("Index", "Home")); } return(View()); }