private SpyClass GrabData() { int electionsRigged, Subterfuge; SpyClass newData = new SpyClass(); newData.Name = assetNameTextBox.Text; int.TryParse(electionsRiggedTextBox.Text, out electionsRigged); int.TryParse(subterfugeTextBox.Text, out Subterfuge); newData.ElectionsRigged = electionsRigged; newData.SubterfugePerformed = Subterfuge; return(newData); }
private void InsertNewInformation(SpyClass newData) { int checkUser = 0; foreach (var el in spyList) { if (String.Equals(el.Name, newData.Name)) { checkUser = 1; el.ElectionsRigged += newData.ElectionsRigged; el.SubterfugePerformed += newData.SubterfugePerformed; } } if (checkUser == 0) { spyList.Add(newData); } }
protected void resultButton_Click(object sender, EventArgs e) { spyList = (List <SpyClass>)ViewState["SpyListValue"]; //check name textbox has been filled in not null not whitespace if (CheckIfNameSpaceHasBeenFilledIn()) { //create object SpyClass newData = GrabData(); //check if spy already is in list InsertNewInformation(newData); // display information DisplaySpyList(); ViewState["SpyListValue"] = spyList; } }