예제 #1
0
 public ActionResult GetEmpData()
 {
     using (EmpDBConn db = new EmpDBConn())
     {
         List <Employee> empList = db.Employees.ToList <Employee>();
         return(Json(new { data = empList }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #2
0
 public ActionResult AddEmpDetail(Employee emp)
 {
     using (EmpDBConn db = new EmpDBConn())
     {
         db.Employees.Add(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Record Saved Successfully", JsonRequestBehavior.AllowGet }));
     }
 }
예제 #3
0
 public ActionResult DeleteEmployee(int id)
 {
     using (EmpDBConn db = new EmpDBConn())
     {
         Employee emp = db.Employees.Where(x => x.ID == id).FirstOrDefault <Employee>();
         db.Employees.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Record deleted succcessfully" }, JsonRequestBehavior.AllowGet));
     }
 }