public int addItemAndReturnId(coordinatesAndSound item) { List<coordinatesAndSound> objectStored = getListItems(); FileStream stream = storedFile.OpenFile(fileName, FileMode.Open); string fileString; if (objectStored != null) { coordinatesAndSound maxId = objectStored.OrderBy(m => m.id).LastOrDefault(); if (maxId != null) item.id = maxId.id + 1; else item.id = 1; } else { item.id = 1; objectStored = new List<coordinatesAndSound>(); } objectStored.Add(item); fileString = serialize(objectStored); BinaryWriter writer = new BinaryWriter(stream); writer.Write(fileString); writer.Close(); stream.Close(); return item.id; }
private void yesHold(object sender, System.Windows.Input.GestureEventArgs e) { coordinatesAndSound item = new coordinatesAndSound(); Database db = new Database(); string soundText = convertBytesToString(myMicrophone.streamMicrophone.ToArray()); item = new coordinatesAndSound(lat, lon, soundText); db.addItemAndReturnId(item); sound.play("routemode"); NavigationService.GoBack(); }
public coordinatesAndSound findLocalDataBaseForLatLongAndSoundById(int id) { coordinatesAndSound item = new coordinatesAndSound(); List<coordinatesAndSound> storedItens = getListItems(); item = (from stored in storedItens where stored.id == id select stored).FirstOrDefault(); return item; }