public ActionResult AddOrEdit(BAccountHolder emp) { try { if (emp.ImageUpload != null) { string fileName = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName); string extension = Path.GetExtension(emp.ImageUpload.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; emp.ImagePath = "~/AppFiles/Images/" + fileName; emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName)); } using (BankSystemDB_ArifEntities db = new BankSystemDB_ArifEntities()) { if (emp.BAccountHolderID == 0) { db.BAccountHolders.Add(emp); db.SaveChanges(); } else { db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); } } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "BranchID,BranchName,City")] Branch branch) { if (ModelState.IsValid) { db.Entry(branch).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branch)); }
public ActionResult Edit(EmployeeVM employeeVM) { if (ModelState.IsValid) { var employee = Mapper.Map <Employee>(employeeVM); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeVM)); }
public ActionResult Edit([Bind(Include = "LoanId,CustomerName,BranchID,IssueDate,PrincipleAmount,Interest,Total")] Loan loan) { if (ModelState.IsValid) { db.Entry(loan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName", loan.BranchID); return(View(loan)); }