public AddDivePresenter(AddDiveView view, ProjectMainWindow window, SubContestBranch subContest, Contestant contestant, Dive dive = null) { this.View = view; this.window = window; this.SubContest = subContest; CurrentContestant = contestant; if (dive != null) { View.TextBoxDiveCode.Text = dive.Code.Code; View.TextBoxDiveMultiplier.Text = dive.Code.Multiplier.ToString(); } View.EventAddDive += AddDiveToContestant; }
/// <summary> /// Opens up a AddDiveView form and waits for the result /// </summary> private void AddDive() { SubContestBranch subContestBranch = GetSelectedSubContest(); Contestant contestant = GetSelectedContestant(); AddDiveView addDiveView = new AddDiveView(); AddDivePresenter addDivePresenter = new AddDivePresenter(addDiveView, window, subContestBranch, contestant); if (subContestBranch != null && contestant != null) { if (addDiveView.ShowDialog() == DialogResult.OK) { UpdateDivesListView(); } } }
/// <summary> /// Updates a existing dive with new information /// </summary> private void ModifyDive() { SubContestBranch subContestBranch = GetSelectedSubContest(); Contestant contestant = GetSelectedContestant(); Dive dive = GetSelectedDive(); AddDiveView modifyView = new AddDiveView(); AddDivePresenter presenter = new AddDivePresenter(modifyView, window, subContestBranch, contestant, dive); if (subContestBranch != null && contestant != null && dive != null) { if (modifyView.ShowDialog() == DialogResult.OK) { subContestBranch.RemoveExistingDive(contestant, dive); UpdateDivesListView(); } } }