示例#1
0
        public void AddProblem(string name, int points)
        {
            db.Problems.Add(new Problem
            {
                Name   = name,
                Points = points,
            });

            db.SaveChanges();
        }
        public void Create(string problemId, string userId, string code)
        {
            var problemMaxpoints = db
                                   .Problems
                                   .Where(x => x.Id == problemId)
                                   .Select(x => x.Points)
                                   .FirstOrDefault();

            db.Submissions
            .Add(new Submission
            {
                ProblemId      = problemId,
                UserId         = userId,
                Code           = code,
                CreatedOn      = DateTime.UtcNow,
                AchievedResult = random.Next(0, problemMaxpoints + 1),
            });

            db.SaveChanges();
        }
示例#3
0
        public void CreateProblem(string name, int points, string userId)
        {
            var problem = new Problem
            {
                Name   = name,
                Points = points,
                UserId = userId
            };

            dbContext.Problems.Add(problem);
            dbContext.SaveChanges();
        }
示例#4
0
        public void UserRegistration(string username, string email, string password)
        {
            var hashPassword = Hash(password);
            var user         = new User
            {
                Username = username,
                Email    = email,
                Password = hashPassword,
            };

            db.Users.Add(user);
            db.SaveChanges();
        }