public ActionResult Create(FormCollection collection, HttpPostedFileBase fileUpload) { try { using (var context = new SiteContainer()) { var banner = new Banner(); TryUpdateModel(banner, new[] { "Description", "Link", "Price" }); if (fileUpload != null) { string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); fileUpload.SaveAs(filePath); banner.ImageSource = fileName; } context.AddToBanner(banner); context.SaveChanges(); return RedirectToAction("Index"); } } catch { return View(); } }