public ActionResult Manage([Bind(Include = "DriverID,DriverName,Mobile,IdPicture,UploadedFile")] DriverDets drv) { Driver d = new Driver { DriverID = drv.DriverID, DriverName = drv.DriverName, Mobile = drv.Mobile, }; if (drv.UploadedFile != null) { string fn = drv.UploadedFile.FileName.Substring(drv.UploadedFile.FileName.LastIndexOf('\\') + 1); fn = drv.DriverName + "_" + fn; string SavePath = System.IO.Path.Combine(Server.MapPath("~/Images"), fn); drv.UploadedFile.SaveAs(SavePath); d.IdPicture = fn; } else { d.IdPicture = drv.IdPicture; } base.BaseSave <Driver>(d, drv.DriverID > 0); return(RedirectToAction("Index")); }
public ActionResult Manage(int?id) { var rec = base.BaseCreateEdit <Driver>(id, "DriverID"); if (id != null) { DriverDets ci = new DriverDets() { DriverID = rec.DriverID, DriverName = rec.DriverName, Mobile = rec.Mobile, IdPicture = rec.IdPicture }; return(View(ci)); } else { DriverDets ci = new DriverDets() { }; return(View(ci)); } }