// GET: Emp public ActionResult Index() { EmpDbHandle dbhandle = new EmpDbHandle(); ModelState.Clear(); return(View(dbhandle.GetEmployee())); }
public List <Employee> Get() { EmpDbHandle dbhandle = new EmpDbHandle(); List <Employee> li = new List <Employee>(); li = dbhandle.GetAll(); return(li); }
public ActionResult Edit(int id, Employee em) { try { EmpDbHandle edb = new EmpDbHandle(); edb.UpdateEmployeeDetails(em); return(RedirectToAction("Index")); } catch { return(View()); } }
public IHttpActionResult Put(int id, Employee emp) { EmpDbHandle dbhandle = new EmpDbHandle(); try { dbhandle.UpdateEmp(emp, id); return(Ok()); } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, "Update Failure")); } }
public IHttpActionResult Post(Employee emp) { EmpDbHandle dbhandle = new EmpDbHandle(); try { dbhandle.AddEmp(emp); return(Ok()); } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, "Post Failure")); } }
public HttpResponseMessage delete(int id) { EmpDbHandle dbHandle = new EmpDbHandle(); try { dbHandle.DeleteEmp(id); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); // return Content(HttpStatusCode.BadRequest, "Delete Failure"); } }
// GET: Emp/Delete/5 public ActionResult Delete(int id) { try { EmpDbHandle edb = new EmpDbHandle(); if (edb.DeleteEmployeeDetails(id)) { ViewBag.AlertMsg = "Employee Deleted Successfully"; } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Employee em) { try { if (ModelState.IsValid) { EmpDbHandle edb = new EmpDbHandle(); if (edb.AddEmployee(em)) { ViewBag.Message = "Employee Details Added Successfully"; ModelState.Clear(); } } return(View()); } catch { return(View()); } }
// GET: Emp/Edit/5 public ActionResult Edit(int id) { EmpDbHandle edb = new EmpDbHandle(); return(View(edb.GetEmployee().Find(em => em.id == id))); }