public ActionResult Create(InstituteDetailModel instituteDetailModel) { try { if (ModelState.IsValid) { string _PhotoName = ""; if (instituteDetailModel.PhotoName != null && instituteDetailModel.PhotoName.ContentLength > 0) { _PhotoName = Path.GetFileName(instituteDetailModel.PhotoName.FileName); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _PhotoName); instituteDetailModel.PhotoName.SaveAs(_path); } InstituteDetail institute = new InstituteDetail() { ID = instituteDetailModel.ID, Name = instituteDetailModel.Name, RegNo = instituteDetailModel.RegNo, CertficateLink = "/UploadedFiles/" + _PhotoName }; if (instituteDetailModel.ID > 0) { instituteRepository.UpdateInstituteDetail(institute); } else { instituteRepository.InsertInstituteDetail(institute); } } else { return(View(instituteDetailModel)); } return(RedirectToAction("Index", "Manage", new { area = "Admin" })); } catch (Exception) { return(View(instituteDetailModel)); } }