public ActionResult Login(HeaderInfoController headerInfoController, string returnUrl) { if (_authenticationService.IsAuthenticated) return RedirectToAction("index", "home"); return View(new LoginViewModel(returnUrl, _authenticationService.IsAuthenticated)); }
public ActionResult Edit(HeaderInfoController headerInfoController, int id) { var user = _accountService.GetUserById(id); if (user == null) return View("NotFound"); if (user.Id != _authenticationService.CurrentUserId) return View("Unauthorized"); return View(new UserProfileUpdateViewModel {UserName = user.DisplayName, UserId = user.Id, Birthday = user.BirthDate, DisplayName = user.DisplayName, Email = user.Email, Location = user.Location, RealName = user.RealName, TwitterUserName = user.TwitterUserName }); }
public ActionResult Index(HeaderInfoController headerInfoController, SidebarController sidebarController, PuzzleSortType? sortType, int? page, int? pageSize) { sortType = sortType ?? PuzzleSortType.Newest; page = page ?? 1; pageSize = pageSize ?? 15; //Get sorted puzzles var puzzles = _puzzleService.GetPuzzleDetailView(sortType.Value, page.Value, pageSize.Value); var viewModel = new PuzzleListViewModel("Welcome", puzzles, sortType.Value, _authenticationService.IsAuthenticated, _authenticationService.CurrentUserId); return View(viewModel); }
public ActionResult HowToPlay(HeaderInfoController headerInfoController) { if (!_authenticationService.IsAuthenticated) { if (Request.Cookies["ShowNotification"] != null) Request.Cookies["ShowNotification"].Value = bool.TrueString; else { var cookie = new HttpCookie("ShowNotification", bool.FalseString); cookie.Domain = Settings.Host; Response.AppendCookie(cookie); } } return View(); }
public ActionResult Display(HeaderInfoController headerInfoController, int id, string userName, PuzzleSortType? sortType, int? page, int? pageSize) { sortType = sortType ?? PuzzleSortType.Newest; page = page ?? 1; pageSize = pageSize ?? 10; var user = _accountService.GetUserById(id); if (user == null) return View("NotFound"); var loggedInUserId = _authenticationService.CurrentUserId; var lastActivity = _accountService.GetLastActivityDate(user.Id); var profileVM = new UserProfileViewModel(user, loggedInUserId, lastActivity); return View("Display", profileVM); }
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}); }
public ActionResult Edit(HeaderInfoController headerInfoController, UserProfileUpdateViewModel userProfile) { var user = _accountService.GetUserById(userProfile.UserId); if (user == null) throw new System.IO.FileNotFoundException(); user.BirthDate = userProfile.Birthday; user.DisplayName = userProfile.DisplayName; user.Email = userProfile.Email; user.Location = userProfile.Location; user.PreferredUserName = userProfile.DisplayName; user.RealName = userProfile.RealName; user.TwitterUserName = userProfile.TwitterUserName; if (!user.IsValid) { ModelState.AddModelErrors(user.RuleViolations); return View(userProfile); } _accountService.UpdateUser(user); return RedirectToAction("Display", new { id = userProfile.UserId, userName = userProfile.DisplayName }); }
public ActionResult Index(HeaderInfoController headerInfoController, PlayerSortType? sortType, int? page) { sortType = sortType ?? PlayerSortType.Reputation; page = page ?? 1; var users = _accountService.GetUsers(page.Value, 28, sortType.Value); var userVms = users.Select(x => new UserInfoViewModel(x)).AsCustomPagination(users.PageNumber, users.PageSize, users.TotalItems); return View(new UserProfileListViewModel(userVms, sortType.Value)); }
public ActionResult Create(HeaderInfoController headerInfoController, SidebarController sidebarController) { return View(); }
public ActionResult Themes(HeaderInfoController headerInfoController, SidebarController sidebarController, int? page, int? pagesize, ThemeSortType? sortType) { page = page ?? 1; pagesize = pagesize ?? 40; sortType = sortType ?? ThemeSortType.Popular; //Get sorted themes var themes = _puzzleService.GetThemes(pagesize.Value, page.Value, sortType.Value); var viewModel = new ThemeListViewModel(GetPageTitle(sortType.Value), themes, sortType.Value); return View(viewModel); ////Get sorted puzzles //IPagination<Puzzle> puzzles = _puzzleService.GetPuzzles(sortType.Value, page.Value, pageSize.Value); ////Get all the votes for the user for the puzzles that are to be displayed. //IEnumerable<Vote> votes = null; //IEnumerable<int> leadingPuzzles = null; //if (_authenticationService.IsAuthenticated) //{ // votes = _puzzleService.GetVotes(puzzles, _authenticationService.CurrentUserId); // leadingPuzzles = _puzzleService.GetPuzzlesLedByUser(puzzles, _authenticationService.CurrentUserId); //} //var viewModel = new PuzzleListViewModel(GetPageTitle(sortType.Value), puzzles, sortType.Value, _authenticationService.IsAuthenticated, votes, leadingPuzzles); //return View(viewModel); }
public ActionResult Themed(HeaderInfoController headerInfoController, SidebarController sidebarController, string themes, PuzzleSortType? sortType, int? page, int? pageSize) { sortType = sortType ?? PuzzleSortType.Newest; page = page ?? 1; pageSize = pageSize ?? 15; //Get sorted puzzles var themeList = Theme.GetThemesFromString(themes); IPagination<PuzzleDetailView> puzzles = _puzzleService.GetPuzzleDetailView(sortType.Value, page.Value, pageSize.Value, themeList); var viewModel = new PuzzleListViewModel(GetThemedPageTitle(sortType.Value, themeList), puzzles, sortType.Value, _authenticationService.IsAuthenticated, _authenticationService.CurrentUserId) {Themes = themeList}; ViewData["themes"] = themes; return View(viewModel); }
public ActionResult Edit(HeaderInfoController headerInfoController, SidebarController sidebarController, EditPuzzleViewModel viewModel, bool captchaValid) { if (_authenticationService.CurrentUser.Reputation < Settings.MinimumReputationToEditPuzzle) return View("NotPrivaledged"); var themes = Theme.GetThemesFromString(viewModel.Themes); ValidatePuzzleEdit(viewModel, themes, captchaValid); if (!ModelState.IsValid) return View(viewModel); _puzzleService.AddThemesToPuzzle(viewModel.Id, _authenticationService.CurrentUserId, themes); return RedirectToAction("Display", new { id = viewModel.Id }); }
public ActionResult Edit(HeaderInfoController headerInfoController, SidebarController sidebarController, int id) { //Only allow logged in users with high enough reputation to edit the puzzle if (!_authenticationService.IsAuthenticated) return View("Unauthorized"); if (_authenticationService.CurrentUser.Reputation < Settings.MinimumReputationToEditPuzzle) return View("NotPrivaledged"); var puzzle = _puzzleService.GetPuzzleById(id); if (puzzle == null) return View("NotFound"); //Only show puzzles that have not been verified to the user who created them. if (!puzzle.IsVerified) { if (puzzle.User.Id != _authenticationService.CurrentUserId) return View("NotFound"); } var vm = new EditPuzzleViewModel(puzzle); return View(vm); }
public ActionResult Display(HeaderInfoController headerInfoController, SidebarController sidebarController, int id) { var puzzle = _puzzleService.GetPuzzleById(id); if (puzzle == null) return View("NotFound"); //Only show puzzles that have not been verified to the user who created them. if (!puzzle.IsVerified) { if(puzzle.User.Id != _authenticationService.CurrentUserId) return View("NotFound"); } puzzle.Solutions = _puzzleService.GetSolutions(puzzle.Id); puzzle.Votes = _puzzleService.GetVotes(puzzle.Id); var latestSolution = puzzle.Solutions.Where(x => x.UserId == _authenticationService.CurrentUserId).LastOrDefault(); if (latestSolution != null) { latestSolution.Steps = _puzzleService.GetSteps(latestSolution.Id); } var bestSolution = puzzle.Solutions.Where(x => x.UserId == _authenticationService.CurrentUserId).OrderByDescending(x => x.PointsAwarded).FirstOrDefault(); if (bestSolution != null) { bestSolution.Steps = _puzzleService.GetSteps(bestSolution.Id); } var vote = puzzle.Votes.Where(x => x.UserId == _authenticationService.CurrentUserId).SingleOrDefault(); var voteType = vote == null ? VoteType.None : vote.VoteType; var userSolutionCount = puzzle.Solutions.Where(x => x.UserId == _authenticationService.CurrentUserId).Count(); var groupedSolutions = puzzle.Solutions.GroupBy(x => x.UserId); var topSolutions = new List<Solution>(); foreach (var group in groupedSolutions) { topSolutions.Add(group.OrderBy(x => x.StepCount).First()); } var puzzleLeaderBoard = topSolutions.OrderBy(x => x.StepCount).CreateOrderedEnumerable(x => x.DateCreated, new StandardComparer<DateTime>(), false).Take(10).Select(x => new SolutionViewModel(x, _accountService.GetUserById(x.UserId))); var viewModel = new PuzzleViewModel(puzzle, voteType, latestSolution, bestSolution, userSolutionCount, puzzleLeaderBoard, puzzle.User.Id == _authenticationService.CurrentUserId, false); return View(viewModel); }
public ActionResult Index(HeaderInfoController headerInfoController, SidebarController sidebarController) { var badges = _accountService.GetAvailableBadges().OrderBy(x => x.Level); return View(badges); }
public ActionResult About(HeaderInfoController headerInfoController) { return View(); }
public ActionResult Continue(HeaderInfoController headerInfoController, string topic) { //For some reason the url /wiki?topic=Washington,_D.C is not being mapped properly //so I need to directly check the querystring. var newTopic = topic; if (string.IsNullOrEmpty(topic) && Request.QueryString.AllKeys.Contains("topic")) { newTopic = Request.QueryString["topic"]; } if (!_gameService.IsPuzzleInProgress) { //Shows the main page if the url is the root www.wikipediamaze.com/wiki if (string.IsNullOrEmpty(newTopic)) newTopic = "Main_Page"; var tp = _topicService.GetTopicByName(newTopic); if (tp != null) { return Content(_topicService.GetTopicHtml(newTopic), "text/html"); } } var puzzleInfo = _gameService.ContinuePuzzle(newTopic); if (puzzleInfo.IsSolved) return RedirectToAction("Display", "Puzzles", new {id = puzzleInfo.PuzzleId}); return Content(_topicService.GetTopicHtml(puzzleInfo.CurrentTopic.Name), "text/html"); }
public ActionResult Start(HeaderInfoController headerInfoController, SidebarController sidebarController, int id) { var result = _gameService.StartPuzzle(id); return RedirectToAction("Continue", new { topic = result.StartTopic.Name }); }
public ActionResult GoBack(HeaderInfoController headerInfoController, SidebarController sidebarController) { var result = _gameService.GoBack(); return RedirectToAction("Continue", new { topic = result.PreviousTopic.Name }); }