public ActionResult Details(string gamertag, ServiceRecord serviceRecord, int?id, string slug) { if (id == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "There was no specified playlist id, the url must have been malformed.")); } var skillRank = serviceRecord.SkillRanks.FirstOrDefault(r => r.PlaylistId == id); if (skillRank == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "The specified playlist doesn't exist. It either was purged by 343, or never existed.")); } var playlist = MetadataHelpers.GetPlaylist(skillRank.PlaylistId); if (playlist == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "The specified playlist doesn't exist. It either was purged by 343, or never existed. Try waiting for 343 to update their systems and try again in 30 minutes.")); } if (skillRank.PlaylistName.ToSlug() != slug) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Details", "Csr", new { id, slug = skillRank.PlaylistName.ToSlug() }), FlashMessage.FlashMessageType.Warning, "Haha!", "Nice try changing the slug m8.")); } return (View(new CsrDetailViewModel(serviceRecord, GlobalStorage.H4Manager.GetPlaylistOrientation(skillRank.PlaylistId), serviceRecord.SkillRanks.FirstOrDefault(r => r.PlaylistId == id), MetadataHelpers.GetPlaylist(skillRank.PlaylistId)))); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var username = (filterContext.ActionParameters["slug"] ?? "").ToString().Trim().ToLower(); using (var sqlStorage = new SqlStorage()) { sqlStorage.Configuration.LazyLoadingEnabled = false; var branchIdentity = sqlStorage.BranchIdentities .Include(i => i.BranchRole) .Include(i => i.GamerIdentity) .Include(i => i.BranchIdentitySessions) .Include(i => i.GamerIdentity.Halo4Identities) .Include(i => i.GamerIdentity.ReachIdentities) .FirstOrDefault(i => i.Username.ToLower() == username.ToLower()); if (branchIdentity != null) { filterContext.ActionParameters["BranchIdentity"] = branchIdentity; return; } } filterContext.Result = FlashMessage.RedirectAndFlash(filterContext.HttpContext.Response, new RedirectToRouteResult("Search", new RouteValueDictionary { { "q", username } }), FlashMessage.FlashMessageType.Info, "Unknown Branch Identity", string.Format("The identity '{0}' does not exist.", username)); }
public ActionResult Index(string gamertag, ServiceRecord serviceRecord, string id) { var game = GlobalStorage.HReachManager.GetGameDetails(id); if (game == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "ServiceRecord"), FlashMessage.FlashMessageType.Failure, "Unable to load Game", "It seems the specified game you tried to view doesn't exist, is invalid, or has been purged by 343.")); } return(View(new GameViewModel(serviceRecord, game))); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var gamertag = filterContext.ActionParameters["gamertag"].ToString(); var serviceRecord = GlobalStorage.H4Manager.GetPlayerServiceRecord(gamertag); if (serviceRecord != null) { filterContext.ActionParameters["ServiceRecord"] = serviceRecord; return; } filterContext.Result = FlashMessage.RedirectAndFlash(filterContext.HttpContext.Response, new RedirectToRouteResult("Search", new RouteValueDictionary { { "q", gamertag } }), FlashMessage.FlashMessageType.Info, "Unknown Halo 4 Player", string.Format("The gamertag '{0}' has not played Halo 4.", gamertag)); }
public ActionResult Index(string gamertag, string slug, ServiceRecord serviceRecord) { var commendations = GlobalStorage.H4Manager.GetPlayerCommendations(serviceRecord.Gamertag); if (commendations == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "ServiceRecord", new { gamertag }), FlashMessage.FlashMessageType.Failure, "No cached player commendation", "Branch hasn't cached the commendations for this player, and can't load any new data right now.")); } CommendationCategory commendationCategory; if (!Enum.TryParse(slug, out commendationCategory)) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Commendations", new { slug = CommendationCategory.Weapons.ToString() }), FlashMessage.FlashMessageType.Info, "Couldn't find Commendation Type", "Branch was unable to find that specific commendation type, so we took you to a familiar, and safe place.")); } return(View(new CommendationsViewModel(serviceRecord, commendations.Commendations, commendationCategory))); }
public ActionResult Index(string gamertag, ServiceRecord serviceRecord, string slug) { GameMode gameMode; Enum.TryParse(slug, out gameMode); var page = int.Parse(Request.QueryString["page"] ?? "0"); if (page < 0) { page = 0; } const int count = 25; dynamic gameHistory; switch (gameMode) { case GameMode.Customs: case GameMode.WarGames: gameHistory = GlobalStorage.H4Manager.GetPlayerGameHistory <GameHistoryModel.WarGames>( serviceRecord.Gamertag, (page * count), count, gameMode); if (gameHistory == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "ServiceRecord", new { area = "Halo4", gamertag }), FlashMessage.FlashMessageType.Failure, "No cached game history", "Branch hasn't cached the game history for this player, and can't load any new data right now.")); } return(View("WarGames", new HistoryViewModel <GameHistoryModel.WarGames>( serviceRecord, gameHistory, gameMode, page))); case GameMode.Campaign: gameHistory = GlobalStorage.H4Manager.GetPlayerGameHistory <GameHistoryModel.Campaign>( serviceRecord.Gamertag, (page * count), count, gameMode); if (gameHistory == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "ServiceRecord", new { area = "Halo4", gamertag }), FlashMessage.FlashMessageType.Failure, "No cached game history", "Branch hasn't cached the game history for this player, and can't load any new data right now.")); } return(View("Campaign", new HistoryViewModel <GameHistoryModel.Campaign>( serviceRecord, gameHistory, gameMode, page))); case GameMode.SpartanOps: gameHistory = GlobalStorage.H4Manager.GetPlayerGameHistory <GameHistoryModel.SpartanOps>( serviceRecord.Gamertag, (page * count), count, gameMode); if (gameHistory == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "ServiceRecord", new { area = "Halo4", gamertag }), FlashMessage.FlashMessageType.Failure, "No cached game history", "Branch hasn't cached the game history for this player, and can't load any new data right now.")); } return(View("SpartanOps", new HistoryViewModel <GameHistoryModel.SpartanOps>( serviceRecord, gameHistory, gameMode, page))); default: return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "History", new { slug = GameMode.WarGames.ToString() }), FlashMessage.FlashMessageType.Info, "Couldn't find specified Game Mode", "Branch was unable to find that specific game mode, so we took you to a familiar, and safe place.")); } }
// // GET: /Search/Identity/{ident}?q={q}&page={page:0} public ActionResult Identity(string ident, string q, int?page = 0) { if (page == null || page < 0) { return(RedirectToAction("Identity", "Search", new { ident, q, page = 0 })); } if (String.IsNullOrEmpty(q)) { return(FlashMessage.RedirectAndFlash( Response, RedirectToAction("Index", "Home", new { area = "" }), FlashMessage.FlashMessageType.Info, "Missing Search Term", "Ey man, there was no search term there.")); } if (String.IsNullOrWhiteSpace(ident)) { return(RedirectToAction("Index", "Search", new { q })); } SearchIdent searchIdent; if (!Enum.TryParse(ident, true, out searchIdent)) { return(FlashMessage.RedirectAndFlash( Response, RedirectToAction("Index", "Search"), FlashMessage.FlashMessageType.Info, "Invalid Search Identity", "Now Now Bae.. You can't be searchin' like that.")); } using (var sqlStorage = new SqlStorage()) { List <Halo4Identity> halo4Identities = null; List <ReachIdentity> reachIdentities = null; bool hasMorePages; switch (searchIdent) { case SearchIdent.Halo4: GlobalStorage.H4Manager.GetPlayerServiceRecord(q, true); halo4Identities = sqlStorage.Halo4Identities .Include(i => i.GamerIdentity) .Where(i => i.GamerIdentity.GamerId.Contains(q)) .OrderBy(i => i.GamerIdentity.GamerId) .Skip(12 * ((int)page)) .Take(13) .ToList(); hasMorePages = halo4Identities.Count() == 13; if (hasMorePages) { halo4Identities = halo4Identities.Take(12).ToList(); } break; case SearchIdent.Reach: GlobalStorage.HReachManager.GetPlayerServiceRecord(q, true); reachIdentities = sqlStorage.ReachIdentities .Include(i => i.GamerIdentity) .Where(i => i.GamerIdentity.GamerId.Contains(q)) .OrderBy(i => i.GamerIdentity.GamerId) .Skip(12 * ((int)page)) .Take(13) .ToList(); hasMorePages = reachIdentities.Count() == 13; if (hasMorePages) { reachIdentities = reachIdentities.Take(12).ToList(); } break; default: return(RedirectToAction("Index", "Search", new { q })); } return(View("Identity", new SearchIdentityViewModel(searchIdent, halo4Identities, reachIdentities, q, (int)page, hasMorePages))); } }