Ejemplo n.º 1
0
        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))));
        }