public ActionResult Create([Bind(Include = "Id,Name,CategoryId,Price,Image")] MenuItemSaveViewModel menuItem) { if (menuItem.Image == null || menuItem.Image.ContentLength == 0) { ModelState.AddModelError("Image", "Please select an image to upload."); } else if (!ImageUploader.IsValidImageType(menuItem.Image)) { ModelState.AddModelError("Image", "The file you are attempting to upload is not an image."); } if (ModelState.IsValid) { var imageUrl = ImageUploader.Upload(menuItem.Image); _db.MenuItems.Add(new MenuItem() { Name = menuItem.Name, Price = menuItem.Price, CategoryId = menuItem.CategoryId, Image = imageUrl }); _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(_db.Categories, "Id", "Name", menuItem.CategoryId); return(View(menuItem)); }