public ActionResult Register(TournamentRegisterViewModel userData) { if (userData.AccountID == account.Model.AccountID) { Models.Tournament viewModel = new Models.Tournament(service, userData.TournamentID); if (viewModel.AddUser(account, Permission.TOURNAMENT_STANDARD)) { Session["Message"] = "You have been registered to this tournament"; Session["Message.Class"] = ViewError.SUCCESS; } else { Session["Message"] = "We were unable to add you to the tournament"; Session["Message.Class"] = ViewError.ERROR; } } else { Session["Message"] = "You must login to register for this tournament"; Session["Message.Class"] = ViewError.ERROR; return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Tournament", "Tournament", new { guid = userData.TournamentID })); }
public ActionResult Deregister(TournamentRegisterViewModel userData) { if (userData.AccountID == account.Model.AccountID) { Models.Tournament viewModel = new Models.Tournament(service, userData.TournamentID); if (viewModel.RemoveUser(account.Model.AccountID)) { Session["Message"] = "You have been removed from this tournament."; Session["Message.Class"] = ViewError.SUCCESS; } else { Session["Message"] = "We could not remove you from the tournament due to an error."; Session["Message.Class"] = ViewError.ERROR; } } else { Session["Message"] = "You must login to do this action."; Session["Message.Class"] = ViewError.ERROR; return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Tournament", "Tournament", new { guid = userData.TournamentID })); }
public ActionResult Tournament(String guid, String inviteCode) { int tournamentId = ConvertToInt(guid); Models.Tournament tourny = new Models.Tournament(service, tournamentId); if (tournamentId == 0) { Session["Message"] = "This tournament is invalid."; Session["Message.Class"] = ViewError.ERROR; return(RedirectToAction("Index", "Tournament")); } if (tourny.Model != null) { bool isAdmin = tourny.IsAdmin(account.Model.AccountID); bool isParticipant = tourny.IsParticipent(account.Model.AccountID); // Should we check for registrations or view the tournament? if (!tourny.Model.InProgress && !isAdmin) { // Verify if the user has an invite code or the invite code is valid if (tourny.Model.PublicRegistration || tourny.Model.InviteCode == inviteCode) { TournamentRegisterViewModel fields = new TournamentRegisterViewModel() { AccountID = account.Model.AccountID, TournamentID = tourny.Model.TournamentID }; // Allow the tournament registration to be shown ViewBag.Tournament = tourny.Model; ViewBag.isRegistered = tourny.isRegistered(account.Model.AccountID); ViewBag.CanRegister = tourny.CanRegister(); return(View("RegisterForm", fields)); } else { Session["Message"] = "This tournament is not accepting registrations."; Session["Message.Class"] = ViewError.WARNING; } } else { // Verify if the user is allowed to view the tournament if (tourny.Model.PublicViewing || tourny.Model.InviteCode == inviteCode || isAdmin || isParticipant) { return(View("Tournament", tourny)); } else { Session["Message"] = "This tournament is not available to view."; Session["Message.Class"] = ViewError.WARNING; } } } else { Session["Message"] = "The tournament you're looking for doesn't exist or is not publicly shared."; Session["Message.Class"] = ViewError.WARNING; } return(RedirectToAction("Search", "Tournament")); }