Ejemplo n.º 1
0
        public void RelateShortTag(long shortId, long tagId, long authorId, Guid shortClientId, Guid tagClientId)
        {
            // with no return value, allow any potential exceptions to bubble up
            var shortTagJoin = new ShortTagJoin
            {
                ShortId       = shortId,
                TagId         = tagId,
                AuthorId      = authorId,
                ShortClientId = shortClientId,
                TagClientId   = tagClientId,
            };

            _dbContext.ShortTagJoin.Add(shortTagJoin);
            _dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public bool UnrelateShortTag(long shortId, long tagId, long authorId)
        {
            try
            {
                var shortTagJoin = new ShortTagJoin
                {
                    ShortId  = shortId,
                    TagId    = tagId,
                    AuthorId = authorId,
                };
                _dbContext.ShortTagJoin.Remove(shortTagJoin);
                _dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Encountered exception while attempting to remove relationship between shortId [{shortId}] and tagId [{tagId}]: {ex.Message}");
                Console.WriteLine(ex.StackTrace);
                return(false);
            }

            return(true);
        }