コード例 #1
0
        public void RelatePromptPersonification(long promptId, long personificationId, long authorId, Guid promptClientId, Guid personificationClientId)
        {
            // with no return value, allow any potential exceptions to bubble up
            var promptPersonificationJoin = new PromptPersonificationJoin
            {
                PromptId                = promptId,
                PersonificationId       = personificationId,
                AuthorId                = authorId,
                PromptClientId          = promptClientId,
                PersonificationClientId = personificationClientId,
            };

            _dbContext.PromptPersonificationJoin.Add(promptPersonificationJoin);
            _dbContext.SaveChanges();
        }
コード例 #2
0
        public bool UnrelatePromptPersonification(long promptId, long personificationId, long authorId)
        {
            try
            {
                var promptPersonificationJoin = new PromptPersonificationJoin
                {
                    PromptId          = promptId,
                    PersonificationId = personificationId,
                    AuthorId          = authorId,
                };
                _dbContext.PromptPersonificationJoin.Remove(promptPersonificationJoin);
                _dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Encountered exception while attempting to remove relationship between promptId [{promptId}] and personificationId [{personificationId}]: {ex.Message}");
                Console.WriteLine(ex.StackTrace);
                return(false);
            }

            return(true);
        }