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"); }