Beispiel #1
0
        public async Task AddDojo(Dojo dojo)
        {
            var latestId = await _context.Dojos.Select(d => d.Id).MaxAsync();

            dojo.Id = latestId + 1;

            await _context.Dojos.AddAsync(dojo);

            await _context.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task UpdateUser(PublicUserData publicUser)
        {
            var user = await _userManager.FindByIdAsync(publicUser.Id);

            user.NickName             = publicUser.NickName;
            user.PreferredLanguage    = publicUser.PreferredLanguage;
            user.PreferredEditorTheme = publicUser.PreferredEditorTheme;

            await _userManager.UpdateAsync(user);

            await _context.SaveChangesAsync();
        }
        public async Task AddSolutionAsync(Solution solution, string userId)
        {
            solution.UserId         = userId;
            solution.SubmissionDate = DateTime.UtcNow;
            solution.SubmissionDate = solution.SubmissionDate.AddHours(2);

            var result = FindSolution(solution).Result;

            if (result != null)
            {
                result.Code = solution.Code;
            }
            else
            {
                _context.Solutions.Add(solution);

                var dojoScore = await GetScoreByDojoIdAsync(solution.DojoId);
                await UpdateUserScoreOnSubmitAsync(dojoScore, userId, solution.DojoId);
            }

            await _context.SaveChangesAsync();
        }