예제 #1
0
        public async Task Tag(File file, Tag tag)
        {
            long?fileId = await FindOrCreate(file);

            var tagId = _sqLiteTag.FindOrCreate(tag);

            _db.ExecuteNonQuery("INSERT INTO FileTags (TagId, FileId) VALUES(@tagId, @fileId);", new SqliteParameter("@tagId", tagId), new SqliteParameter("@fileId", fileId));
        }
예제 #2
0
        public bool Destroy(Tag tag)
        {
            var tagId = Find(tag);

            if (tagId.HasValue)
            {
                var tagIdParameter = new SqliteParameter("@tagId", tagId);
                _db.ExecuteNonQuery("DELETE FROM FileTags WHERE TagId = @tagId", tagIdParameter);
                _db.ExecuteNonQuery("DELETE FROM Tags WHERE Id = @tagId", tagIdParameter);
            }

            return(tagId.HasValue);
        }