Example #1
0
        private async Task<AuthorBot> CreateBot(string name, string code = null, int? rootId = null, int? parentId = null, int version = 1)
        {
            var bot = new Bot
            {
                Type = (int)BotTypes.Javascript,
                Name = name,
                Code = code ?? JsBots.JsBot.DefaultSourceCode
            };
            _context.Bots.Add(bot);
            await _context.SaveChangesAsync();

            var authorBot = new AuthorBot
            {
                RootId = rootId,
                ParentId = parentId,
                BotId = bot.Id,
                AuthorId = Author.Id,
                Created = DateTime.UtcNow,
                Version = version,
                Status = (int)BotStatus.Draft
            };
            _context.Add(authorBot);
            await _context.SaveChangesAsync();

            return authorBot;
        }
Example #2
0
 public static int GetRootId(this AuthorBot authorBot)
 {
     return(authorBot.RootId ?? authorBot.Id);
 }