Ejemplo n.º 1
0
        public ActionResult Create( Problem problem )
        {
            if ( ModelState.IsValid )
            {
                problem.CreateDate = DateTime.UtcNow;
                problem.Description = HttpUtility.HtmlDecode( problem.Description );
                problem.Content = HttpUtility.HtmlDecode( problem.Content );

                db.Problems.Add( problem );
                db.SaveChanges();
                return RedirectToAction( "Index" );
            }

            ViewBag.ChallengeId = new SelectList( db.Challenges, "Id", "Name", problem.ChallengeId );
            return View( problem );
        }
Ejemplo n.º 2
0
        public YourProblem( Problem problem, int userId )
        {
            Entities db = new Entities();

            Problem = problem;

            CanOpen = Security.CanOpen( problem.Id, userId );
            CanSubmit = Security.CanSubmit( problem.Id, userId );

            Solving solving = db.Solvings.SingleOrDefault( s => s.ProblemId == problem.Id && s.UserId == userId );

            if ( solving == null )
            {
                Status = SolvingStatus.NOT_OPEN;
                return;
            }

            FirstAttempt = solving.FirstOpenTime;
            LastAttempt = solving.LastOpenTime;

            Submissions = db.Submissions.Where( s => s.SolvingId == solving.Id ).OrderByDescending( s => s.Time );

            if ( Submissions == null || Submissions.Count() == 0 )
            {
                Status = SolvingStatus.NOT_SUBMIT;
                return;
            }

            Submission firstResolved = Submissions.FirstOrDefault( s => s.Result != null && s.Result != 0 );

            if ( firstResolved == null )
                Status = SolvingStatus.NOT_RESOLVED;
            else
            {
                Status = SolvingStatus.RESOLVED;
                FirstResolved = firstResolved.Time;
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit( Problem problem )
        {
            if ( ModelState.IsValid )
            {
                problem.Description = HttpUtility.HtmlDecode( problem.Description );
                problem.Content = HttpUtility.HtmlDecode( problem.Content );

                db.Entry( problem ).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction( "Index" );
            }
            ViewBag.ChallengeId = new SelectList( db.Challenges, "Id", "Name", problem.ChallengeId );
            return View( problem );
        }