public ActionResult Edit(FormCollection form, int Id) { Employeelist em = dbContext.employees.Single(m => m.Id == Id); em.EmployeeID = Convert.ToInt32(form["EmployeeID"]); em.Prefix = form["Prefix"]; em.FirstName = form["FirstName"]; em.MiddleName = form["MiddleName"]; em.LastName = form["LastName"]; if (form["Gender"] == "Male") { em.Gender = form["Gender"]; } else if (form["Gender"] == "Female") { em.Gender = form["Gender"]; } em.Dob = Convert.ToDateTime(form["Dob"]); em.Designation = form["Designation"]; dbContext.employees.Attach(em); var prf = dbContext.Entry(em); prf.Property(m => m.EmployeeID).IsModified = true; prf.Property(m => m.Prefix).IsModified = true; prf.Property(m => m.FirstName).IsModified = true; prf.Property(m => m.LastName).IsModified = true; prf.Property(m => m.MiddleName).IsModified = true; prf.Property(m => m.Gender).IsModified = true; prf.Property(m => m.Dob).IsModified = true; prf.Property(m => m.Designation).IsModified = true; dbContext.SaveChanges(); return(RedirectToAction("EmployeeManager")); }
public ActionResult Edit(int Id) { if (Session["Login"] != null && Session["Login"].ToString() != "") { Employeelist employeelist = dbContext.employees.Single(m => m.Id == Id); return(View(employeelist)); } else { return(RedirectToAction("Login", "Home")); } }
public ActionResult AddCredential(int id) { if (Session["Login"] != null && Session["Login"].ToString() != "") { Employeelist employeelist = dbContext.employees.Single(m => m.Id == id); Credential cred = new Credential(); cred.EmployeeID = employeelist.EmployeeID; cred.UserName = employeelist.FirstName; return(View(cred)); } else { return(RedirectToAction("Login", "Home")); } }