public static void addTaggings(taggingsModel taggings) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { //INSERT INTO "main"."taggings"("id", "metadata_item_id", "tag_id", "index", "text", "time_offset", "end_time_offset", "thumb_url", "created_at", "extra_data") VALUES (1000, 18, 746, 16, '', NULL, NULL, '', '2020-05-22 15:22:47', ''); //cnn.Execute("insert into taggings (metadata_item_id, tag_id, [index], text, time_offset, end_time_offset, thumb_url, created_at, extra_data) values ( @metadata_item_id, @tag_id, @index, @text, @time_offset, @end_time_offset, @thumb_url, @created_at, @extra_data)", taggings); cnn.Execute("insert into taggings (metadata_item_id, tag_id, [index], text, thumb_url, created_at, extra_data) values ( @metadata_item_id, @tag_id, @index, @text, @thumb_url, @created_at, @extra_data)", taggings); } }
static void createTaggings(metadataModel item, tagsModel tagged) { //search for tagging List <taggingsModel> taggings = LoadTaggings(); taggings = taggings.FindAll(x => x.tag_id.Equals(tagged.id)); //search for already added to taggings int taggingIndex = taggings.FindIndex(x => x.metadata_item_id.Equals(item.id)); //findindex example from ms if (taggingIndex >= 0) { //found Console.WriteLine("Found a tagging at index {0}", taggings[taggingIndex].id); } else { Console.WriteLine("no taggings have been found for \"{0}\" with name {1}", item.tags_director, item.title); //create tagging index taggingsModel newTagging = new taggingsModel(); newTagging.metadata_item_id = item.id; newTagging.tag_id = tagged.id; newTagging.index = 0; newTagging.text = ""; newTagging.thumb_url = string.Empty; //create the time for Plex without ms newTagging.created_at = DateTime.Parse( DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"), System.Globalization.CultureInfo.CurrentCulture ); newTagging.extra_data = string.Empty; Console.WriteLine("Add new tagging"); addTaggings(newTagging); Console.WriteLine("New tagging has been added!"); } }