public ActionResult CreatePartyMember(partymember_view partymember_form_page) { var _person = new person(); _person.firstName = partymember_form_page.firstName; _person.lastName = partymember_form_page.lastName; _person.mainPhone = partymember_form_page.mainPhone; _person.email = partymember_form_page.email; _person.createDate = DateTime.Now; _person.lastUpdate = DateTime.Now; persons1.Insert(_person); persons1.Commit(); var _partymember = new partymember(); _partymember.ID = _person.ID; _partymember.cellPhone = partymember_form_page.cellPhone; _partymember.petDescription = partymember_form_page.petDescription; _partymember.comments = partymember_form_page.comments; _partymember.createDate = DateTime.Now; _partymember.lastUpdate = DateTime.Now; partymembers.Insert(_partymember); partymembers.Commit(); return RedirectToAction("Index"); }
public ActionResult CreatePartyMember(partymember_view partymember_form_page) { //validation check var personfirstname = persons1.GetAll().Where(s => s.firstName.ToUpper().Contains(partymember_form_page.firstName.ToUpper())).ToList(); var personlastname = persons1.GetAll().Where(s => s.lastName.ToUpper().Contains(partymember_form_page.lastName.ToUpper())).ToList(); var personmainphone = persons1.GetAll().Where(s => s.mainPhone.ToUpper().Contains(partymember_form_page.mainPhone.ToUpper())).ToList(); var _person = new person(); _person.firstName = partymember_form_page.firstName; _person.lastName = partymember_form_page.lastName; _person.mainPhone = partymember_form_page.mainPhone; _person.email = partymember_form_page.email; _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"); } persons1.Insert(_person); persons1.Commit(); var _partymember = new partymember(); _partymember.ID = _person.ID; _partymember.cellPhone = partymember_form_page.cellPhone; _partymember.petDescription = partymember_form_page.petDescription; _partymember.comments = partymember_form_page.comments; _partymember.createDate = DateTime.Now; _partymember.lastUpdate = DateTime.Now; partymembers.Insert(_partymember); partymembers.Commit(); return RedirectToAction("Index"); }