public ActionResult Edit(Employee person) { if (ModelState.IsValid) { empHelper.UpdatePerson(person); TempData["Status"] = "Success"; return RedirectToAction("Index"); } return View(person); }
public ActionResult AddPerson(Employee person) { try { if (ModelState.IsValid) { empHelper.UpdatePerson(person); TempData["Status"] = "Success"; return RedirectToAction("Index"); } return View(person); } catch (Exception e) { TempData["Status"] = "Problem"; return RedirectToAction("Index"); } }
public bool UpdatePerson(Employee _person) { using (ISession session = NHibernateHelper.OpenSession()) { var person = session.Get<Employee>(_person.EmployeeId); if (person == null) { person = new Employee(); } person.FirstName = _person.FirstName; person.LastName = _person.LastName; person.Destination = _person.Destination; person.IsGoodPerson = _person.IsGoodPerson; using (ITransaction transaction = session.BeginTransaction()) { session.SaveOrUpdate(person); transaction.Commit(); return true; } } }
public HttpResponseMessage Post(Employee person) { return empHelper.UpdatePerson(person) ? new HttpResponseMessage(HttpStatusCode.OK) : new HttpResponseMessage(HttpStatusCode.BadRequest); }
public bool DeleteUser(Employee person) { return empHelper.DeletePerson(person.EmployeeId) ? true : false; }