public int SaveDevice(device item) { if (item.id != 0) { database.Update(item); return(item.id); } else { return(database.Insert(item)); } }
private void Save_Clicked(object sender, EventArgs e) { var device = new device(); device.name = name.Text; device.idType = type.SelectedIndex + 1; device.isEnable = true; App.database.SaveDevice(device); var devicefinal = App.database.GetDevice().ToList().LastOrDefault(); var userDevice = new userDevice(); userDevice.idDevice = devicefinal.id; userDevice.idUser = MainPage.user.id; App.database.SaveUserDevice(userDevice); Navigation.PopAsync(); }