public ActionResult Create(Barang barang, HttpPostedFileBase uploadimage) { string filePath = ""; if (uploadimage.ContentLength > 0) { string fileName = Guid.NewGuid().ToString() + "_" + uploadimage.FileName; filePath = Path.Combine(HttpContext.Server.MapPath("~/Content/Images"), fileName); uploadimage.SaveAs(filePath); barang.gbr_barang = fileName; } using (BarangDAL svBrg = new BarangDAL()) { try { svBrg.Add(barang); TempData["Pesan"] = Helpers.Message.GetPesan("Sukses !", "success", "Data Barang " + barang.nama_barang + " berhasil ditambah"); } catch (Exception ex) { TempData["Pesan"] = Helpers.Message.GetPesan("Error !", "danger", ex.Message); } } return(RedirectToAction("Index")); }