// GET: /Create public ActionResult CreateStaff() { sessionService.GetSessionID(this.HttpContext, true, true); var staff_view = new staff_view(); return View(staff_view); }
public ActionResult EditStaff(staff_view staff_form_page) { var _person = persons.GetById(staff_form_page.id); _person.firstName = staff_form_page.firstName; _person.lastName = staff_form_page.lastName; _person.mainPhone = staff_form_page.mainPhone; _person.email = staff_form_page.email; _person.lastUpdate = DateTime.Now; persons.Update(_person); persons.Commit(); var _staff = staffs.GetById(staff_form_page.id); // _staff.ID = _person.ID; _staff.role = staff_form_page.role; _staff.lastUpdate = DateTime.Now; staffs.Update(_staff); staffs.Commit(); return RedirectToAction("Index"); }
public ActionResult CreateStaff(staff_view staff_form_page) { var _person = new person(); _person.firstName = staff_form_page.firstName; _person.lastName = staff_form_page.lastName; _person.mainPhone = staff_form_page.mainPhone; _person.email = staff_form_page.email; _person.createDate = DateTime.Now; _person.lastUpdate = DateTime.Now; persons.Insert(_person); persons.Commit(); var _staff = new staff(); _staff.ID = _person.ID; _staff.role = staff_form_page.role; _staff.createDate = DateTime.Now; _staff.lastUpdate = DateTime.Now; staffs.Insert(_staff); staffs.Commit(); return RedirectToAction("Index"); }
public ActionResult CreateStaff(staff_view staff_form_page) { sessionService.GetSessionID(this.HttpContext, true, true); //validation check var personfirstname = persons.GetAll().Where(s => s.firstName.ToUpper().Contains(staff_form_page.firstName.ToUpper())).ToList(); var personlastname = persons.GetAll().Where(s => s.lastName.ToUpper().Contains(staff_form_page.lastName.ToUpper())).ToList(); var personmainphone = persons.GetAll().Where(s => s.mainPhone.ToUpper().Contains(staff_form_page.mainPhone.ToUpper())).ToList(); var _person = new person(); _person.firstName = staff_form_page.firstName; _person.lastName = staff_form_page.lastName; _person.mainPhone = staff_form_page.mainPhone; _person.email = staff_form_page.email; _person.password = sessionService.GetHash("012345"); _person.createDate = DateTime.Now; _person.lastUpdate = DateTime.Now; //first, last name and main phone validation if (_person.firstName == null) { return RedirectToAction("ErrorMessage"); } else if (_person.firstName.Trim().Length > 50) { return RedirectToAction("ErrorMessage"); } else if (_person.lastName == null) { return RedirectToAction("ErrorMessage"); } else if (_person.lastName.Trim().Length > 50) { return RedirectToAction("ErrorMessage"); } else if (_person.mainPhone == null) { return RedirectToAction("ErrorMessage"); } else if (_person.mainPhone.Trim().Length > 30) { return RedirectToAction("ErrorMessage"); } else if (personfirstname.Count() > 0 && personlastname.Count() > 0 && personmainphone.Count() > 0) //else if (personfirstname.Count() > 0 && personlastname.Count() > 0) { return RedirectToAction("ErrorMessage"); } persons.Insert(_person); persons.Commit(); var _staff = new staff(); _staff.ID = _person.ID; _staff.role = staff_form_page.role; _staff.createDate = DateTime.Now; _staff.lastUpdate = DateTime.Now; staffs.Insert(_staff); staffs.Commit(); return RedirectToAction("Index"); }
// GET: /Create public ActionResult CreateStaff() { var staff_view = new staff_view(); return View(staff_view); }