public ActionResult Submit(Int32 id, FormCollection form)
        {
            ContestEntity contest = ViewData["Contest"] as ContestEntity;
            ProblemEntity problem = ContestProblemManager.GetProblem(contest.ContestID, id);

            SolutionEntity entity = new SolutionEntity()
            {
                ProblemID        = problem.ProblemID,
                ContestID        = contest.ContestID,
                ContestProblemID = id,
                SourceCode       = form["code"],
                LanguageType     = LanguageType.FromLanguageID(form["lang"])
            };

            Dictionary <String, Byte> supportLanguages = LanguageManager.GetSupportLanguages(contest.SupportLanguage);

            if (!supportLanguages.ContainsValue(entity.LanguageType.ID))
            {
                return(RedirectToErrorMessagePage("This contest does not support this programming language."));
            }

            String userip = this.GetCurrentUserIP();

            if (!SolutionManager.InsertSolution(entity, userip))
            {
                return(RedirectToErrorMessagePage("Failed to submit your solution!"));
            }

            return(RedirectToAction("List", "Status", new { area = "Contest", cid = contest.ContestID }));
        }
        public ActionResult Show(Int32 id = -1)
        {
            ContestEntity contest = ViewData["Contest"] as ContestEntity;
            ProblemEntity entity  = ContestProblemManager.GetProblem(contest.ContestID, id);

            ViewBag.ContestProblemID = id.ToString();

            return(View(entity));
        }
        public ActionResult Submit(Int32 id = -1)
        {
            ContestEntity contest = ViewData["Contest"] as ContestEntity;
            ProblemEntity problem = ContestProblemManager.GetProblem(contest.ContestID, id);
            IEnumerable <SelectListItem> items = this.GetLanguageItems(contest.SupportLanguage);

            ViewBag.Languages        = items;
            ViewBag.ContestProblemID = id.ToString();

            return(View(problem));
        }