private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (tcFullInfo.SelectedIndex == 0) { int ID = int.Parse(gridPeople[0, gridPeople.SelectedCells[0].RowIndex].Value.ToString()); Person person = people.GetPerson(ID); AddForm form = new AddForm(person, awards.Awards); form.ShowDialog(); if (form.DeleteState) { people.DeletePerson(form.User); } else { people.ReplaceData(form.User); } } else if (tcFullInfo.SelectedIndex == 1) { int ID = int.Parse(gridAwards[0, gridAwards.SelectedCells[0].RowIndex].Value.ToString()); Award award = awards.GetAward(ID); AddForm form = new AddForm(award); form.ShowDialog(); if (form.DeleteState) { foreach (Person i in people.People) { i.GetAwards().RemoveAll(item => item.ID == award.ID); } awards.DeleteAward(form.Award); } else { awards.ReplaceData(form.Award); } } UpdateData(); }
public ActionResult Edit(int id, FormCollection collection, int[] awardSelected) { List <Award> awardStr = new List <Award>(); Person p = personsBL.GetPerson(id); foreach (Award i in awardsBL.Awards) { if (p.GetAwards().Find(item => item.ID == i.ID) == null) { awardStr.Add(i); } } ViewBag.AwardStr = awardStr; foreach (int i in awardSelected) { personsBL.AddAwardPerson(awardsBL.GetAward(i), p); } // ViewBag. = awardStr; try { // p.ID = collection["ID"]; p.FirstName = collection["FirstName"]; p.LastName = collection["LastName"]; p.DateBirth = DateTime.Parse(collection["DateBirth"]); personsBL.ReplaceData(p); return(RedirectToAction("Index")); } catch { return(View()); } }