private void UpdateItem(String caseId, String wsId, Boolean additem) { Boolean caseFound = false; foreach (CaseWS caseWS in caseWSCollection) { if (caseWS.Case.Equals(caseId)) { if (additem) { Int32 index = caseWSCollection.IndexOf(caseWS); caseWSCollection.RemoveAt(index); caseWS.WS = wsId; caseWSCollection.Insert(index, caseWS); } else { caseWSCollection.Remove(caseWS); } caseFound = true; break; } } if (!caseFound && additem) { CaseWS caseWS = new CaseWS(); caseWS.Case = caseId; caseWS.WS = wsId; caseWSCollection.Add(caseWS); } }
private void UpdateItem(String caseId, String awsId, String area, Boolean additem) { Boolean caseFound = false; if (String.IsNullOrWhiteSpace(caseId)) { foreach (CaseWS caseWS in caseWSCollection) { if (caseWS.WS.Equals(awsId)) { caseWS.WS = string.Empty; } } } else { foreach (CaseWS caseWS in caseWSCollection) { if (caseWS.Case.Equals(caseId)) { if (additem) { Int32 index = caseWSCollection.IndexOf(caseWS); if (area == string.Empty) { area = caseWSCollection[index].Area; } caseWSCollection.RemoveAt(index); caseWS.WS = awsId; caseWS.Area = area; caseWSCollection.Insert(index, caseWS); } else { caseWSCollection.Remove(caseWS); } caseFound = true; break; } } if (!caseFound && additem) { CaseWS caseWS = new CaseWS(); caseWS.Case = caseId; caseWS.WS = awsId; caseWS.Area = area; caseWSCollection.Add(caseWS); } } }