Beispiel #1
0
 public bool CreateGroupAudioRecord(GroupAudioRecord gar)
 {
     try
     {
         _DbConnection.Insert(gar);
         return(true);
     }
     catch (System.InvalidOperationException ioe)
     {
         System.Console.WriteLine(ioe.StackTrace);
         return(false);
     }
 }
        private void B_Clicked(object sender, EventArgs e)
        {
            //get recordID, groupID and create list on
            int index = RecordingPane.Children.IndexOf((StackLayout)((Button)sender).Parent);

            Models.AudioRecord record    = user.Recordings[index];
            string             groupName = ((Picker)RecordingsStackLayout.Children[2]).SelectedItem.ToString();

            if (user.Groups.Where(x => x.GroupName == groupName).ToList().Count() > 0)
            {
                Group g;
                int   count = 0;
                using (var db = new Persistence.SQLiteDb())
                {
                    g     = db.GetGroupByName(groupName);
                    count = db.GetGroupAudioRecords().Count();
                }
                GroupAudioRecord gar = new GroupAudioRecord
                {
                    AudioRecordId       = record.ID,
                    GroupId             = g.ID,
                    IsGroupAudioCreator = true
                };
                bool hasShared = false;
                using (var db = new Persistence.SQLiteDb())
                {
                    hasShared = db.CreateGroupAudioRecord(gar);
                }
                string retVal = hasShared ? "Audio shared" : "Something went wrong";
                DisplayAlert("", retVal, "Okay");
            }
            else
            {
                DisplayAlert("", "That group doesn't exist", "Okay");
            }
        }