public void ChangeHop(object value, string name) { var str = value is IEnumerable <object>?string.Join(", ", (IEnumerable <object>) value) : value; //selectedHopID = value.ToString(); if (Model.hops.Count == 0) { hopbase hopw = new hopbase(); hopAddition ha = new hopAddition(); Model.hops.Add(ha); Model.hops[0].hop = hopw; hopState.currentSelectedHopIndex = 0; hopUse = ""; } if (!(String.IsNullOrEmpty(name) || value == null)) { Model.hops[hopState.currentSelectedHopIndex].hop = AllHops.Where(x => x.idString == value).FirstOrDefault(); Model.hops[hopState.currentSelectedHopIndex].hopID = value.ToString(); } if (Model.hops.Count != 0) { hopName = Model.hops[hopState.currentSelectedHopIndex].hop.name; hopUse = Model.hops[hopState.currentSelectedHopIndex].type; } else { hopUse = ""; hopName = ""; } Save(false); }
public string findHopIDFromSelecteHop() { resetSelector(); if (hopState.currentSelectedHopIndex != -1 && Model.hops.Count != 0) { hopbase currentSelection = AllHops.Where(x => x.name == Model.hops[hopState.currentSelectedHopIndex].hop.name).FirstOrDefault(); if (currentSelection == null) { return("-1"); } else { return(currentSelection.idString); } } else { return("-1"); } }