コード例 #1
0
ファイル: UsersRepo.cs プロジェクト: atnartur/Ulearn
        public async Task CreateUlearnBotUserIfNotExists()
        {
            var ulearnBotFound = await db.Users.AnyAsync(u => u.UserName == UlearnBotUsername).ConfigureAwait(false);

            if (!ulearnBotFound)
            {
                var user = new ApplicationUser
                {
                    UserName  = UlearnBotUsername,
                    FirstName = "Ulearn",
                    LastName  = "bot",
                    Email     = "*****@*****.**",
                };
                await userManager.CreateAsync(user, StringUtils.GenerateSecureAlphanumericString(10)).ConfigureAwait(false);

                await db.SaveChangesAsync().ConfigureAwait(false);
            }
        }
コード例 #2
0
ファイル: GradersRepo.cs プロジェクト: atnartur/Ulearn
        public async Task <GraderClient> AddGraderClient(string courseId, string name)
        {
            var clientId = Guid.NewGuid();
            var user     = new ApplicationUser {
                UserName = $"__grader_client_{clientId.GetNormalizedGuid()}__"
            };
            var password = StringUtils.GenerateSecureAlphanumericString(10);
            await userManager.CreateAsync(user, password);

            var client = new GraderClient
            {
                Id       = clientId,
                CourseId = courseId,
                Name     = name,
                User     = user,
            };

            db.GraderClients.Add(client);
            await db.SaveChangesAsync();

            return(client);
        }
コード例 #3
0
ファイル: XQueueRepo.cs プロジェクト: atnartur/Ulearn
        public async Task AddXQueueWatcher(string name, string baseUrl, string queueName, string username, string password)
        {
            var user = new ApplicationUser {
                UserName = $"__xqueue_watcher_{new Guid().GetNormalizedGuid()}__"
            };
            var userPassword = StringUtils.GenerateSecureAlphanumericString(10);
            await userManager.CreateAsync(user, userPassword);

            var watcher = new XQueueWatcher
            {
                Name      = name,
                BaseUrl   = baseUrl,
                QueueName = queueName,
                UserName  = username,
                Password  = password,
                IsEnabled = true,
                User      = user,
            };

            db.XQueueWatchers.Add(watcher);

            await db.SaveChangesAsync();
        }