public ActionResult Create(HeaderInfoController headerInfoController, SidebarController sidebarController, CreatePuzzleViewModel viewModel, bool captchaValid)
        {
            var themes = Theme.GetThemesFromString(viewModel.Themes);

            ValidatePuzzleForCreation(viewModel, themes, captchaValid);

            if(!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var result = _puzzleService.CreatePuzzle(viewModel.StartTopic, viewModel.EndTopic);

            if (!result.Success)
            {
                ModelState.AddModelErrors(result.RuleViolations);
                return View(viewModel);
            }

            _puzzleService.AddThemesToPuzzle(result.PuzzleId, _authenticationService.CurrentUserId, themes);

            return RedirectToAction("Display", new {id = result.PuzzleId});
        }
        private void ValidatePuzzleForCreation(CreatePuzzleViewModel vm, IEnumerable<string> themes, bool captchaValid)
        {
            if (!captchaValid)
                ModelState.AddModelError("Captcha", "Captcha is invalid");

            if (themes.Count() == 0)
                ModelState.AddModelError("Themes", "At least 1 theme is required");

            if (themes.Count() > 5)
                ModelState.AddModelError("Themes", "Can only select up to 5 themes");

            if((vm.StartTopic + "").Trim() == string.Empty)
                ModelState.AddModelError("StartTopic", "Start Topic cannot be blank");
            else if (!Uri.IsWellFormedUriString(vm.StartTopic, UriKind.Absolute))
                ModelState.AddModelError("StartTopic", "Start topic is not a valid Url");

            if ((vm.EndTopic + "").Trim() == string.Empty)
                ModelState.AddModelError("EndTopic", "End Topic cannot be blank");
            else if (!Uri.IsWellFormedUriString(vm.EndTopic, UriKind.Absolute))
                ModelState.AddModelError("EndTopic", "End topic is not a valid Url");
        }