public ActionResult EditT(TenantPersonnel person) { try { using (var db = new TestDemoAstarEntities()) { TenantPersonnel user = db.TenantPersonnel.Find(person.TenantId); user.FirstName = person.FirstName; user.MiddleName = person.MiddleName; user.LastName = person.LastName; user.GenderFk = person.GenderFk; user.NickName = person.NickName; user.PrefixID = person.PrefixID; if (ModelState.IsValid) { db.SaveChanges(); } return(RedirectToAction("Index")); } } catch (Exception ex) { ModelState.AddModelError("Error to edit", ex); return(View()); } }
public ActionResult Delete(int id) { try { using (var db = new TestDemoAstarEntities()) { TenantPersonnel person = db.TenantPersonnel.Find(id); db.TenantPersonnel.Remove(person); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { throw; } }
public ActionResult AddT(TenantPersonnel person) { try { using (var db = new TestDemoAstarEntities()) { person.DOB = DateTime.Now; db.TenantPersonnel.Add(person); if (ModelState.IsValid) { db.SaveChanges(); } return(RedirectToAction("Index")); } } catch (Exception ex) { ModelState.AddModelError("Error to add", ex); return(View()); } }