public ActionResult Create(PersonViewModel personVM) { //Create object of PersonsBL PersonsBL personBL = new PersonsBL(); //Creating object of Person EntityModel Person person = new Person(); person.PersonName = personVM.PersonName; person.Email = personVM.Email; person.Age = personVM.Age; //Invoke the AddPerson method BL (bool isAdded, Guid newGuid) = personBL.AddPerson(person); if (isAdded) { //Go to Index action method of Persons Controller return(RedirectToAction("Index")); } else { //Return plain html / plain string return(Content("Person not added")); } }
public ActionResult Add(FormCollection collection) { try { personsBL.AddPerson(new Person(collection["FirstName"], collection["LastName"], DateTime.Parse(collection["DateBirth"]))); return(RedirectToAction("Index")); } catch { return(View()); } }
private void AddToolStripMenuItem_Click(object sender, EventArgs e) { if (tcFullInfo.SelectedIndex == 0) { AddForm form = new AddForm(true, awards.Awards); form.ShowDialog(); if (form.User != null) { people.AddPerson(form.User); } } else if (tcFullInfo.SelectedIndex == 1) { AddForm form = new AddForm(false, awards.Awards); form.ShowDialog(); if (form.Award != null) { awards.AddAward(form.Award); } } UpdateData(); }