Esempio n. 1
0
 public ActionResult Edit(Employee person)
 {
     if (ModelState.IsValid)
     {
         empHelper.UpdatePerson(person);
         TempData["Status"] = "Success";
         return RedirectToAction("Index");
     }
     return View(person);
 }
Esempio n. 2
0
 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");
     }
 }
Esempio n. 3
0
 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;
         }
     }
 }
Esempio n. 4
0
 public HttpResponseMessage Post(Employee person)
 {
     return empHelper.UpdatePerson(person)
         ? new HttpResponseMessage(HttpStatusCode.OK) : new HttpResponseMessage(HttpStatusCode.BadRequest);
 }
Esempio n. 5
0
 public bool DeleteUser(Employee person)
 {
     return empHelper.DeletePerson(person.EmployeeId) ? true : false;
 }