示例#1
0
        // GET: Missions/duritanium-man
        public ActionResult Details(string link)
        {
            if (string.IsNullOrEmpty(link))
            {
                return(RedirectToAction("index", "home"));
            }
            Mission mission = db.Missions.Where(m => m.MissionLink.Equals(link)).FirstOrDefault();

            if (mission == null)
            {
                return(HttpNotFound());
            }

            //if it is in review or unpubilshed only an aadministrator or the author can view it
            if (mission.Status == Models.FoundryMissionModels.Enums.MissionStatus.InReview ||
                mission.Status == Models.FoundryMissionModels.Enums.MissionStatus.Unpublished)
            {
                if ((mission.Author != null && !mission.Author.UserName.Equals(User.Identity.Name)) &&
                    (!User.IsInRole("Administrator")))
                {
                    return(HttpNotFound());
                }
            }

            //if it is removed only an admnistrator can view it
            if (mission.Status == Models.FoundryMissionModels.Enums.MissionStatus.Removed)
            {
                if (!User.IsInRole("Administrator"))
                {
                    return(HttpNotFound());
                }
            }

            ViewMissionViewModel viewMission = new ViewMissionViewModel()
            {
                Id                   = mission.Id,
                Author               = mission.Author,
                AuthorCrypticTag     = mission.AuthorUserId,
                CrypticId            = mission.CrypticId.ToUpper(),
                Name                 = mission.Name,
                Description          = mission.Description,
                Faction              = mission.Faction,
                FactionImageUrl      = MissionHelper.GetBigFactionImageUrl(mission.Faction),
                MinimumLevel         = mission.MinimumLevel,
                MinimumLevelImageUrl = MissionHelper.GetBigLevelImageUrl(mission.MinimumLevel, mission.Faction),
                DateLastUpdated      = mission.DateLastUpdated,
                Length               = mission.Length,
                Tags                 = mission.Tags.OrderBy(t => t.TagName).ToList(),
                Videos               = mission.Videos.OrderBy(v => v.Order).Select(v => v.YoutubeVideoId).ToList(),
                Status               = mission.Status,
                MissionLink          = mission.MissionLink,
                Images               = mission.Images.OrderBy(i => i.Order).Select(i => i.Filename).ToList(),
                HasExport            = MissionExportHelper.HasExport(mission.Id),
            };

            //It's okay to show the mission now

            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }

            return(View(viewMission));
        }