Ejemplo n.º 1
0
        //
        // GET: /Manage/Index
        public ActionResult Index()
        {
            var model = new ManageIndexViewModel();

            var missions = db.Missions.Where(m => m.Author.UserName.Equals(User.Identity.Name) && m.Status != MissionStatus.Removed).ToList();

            model.Missions = MissionHelper.GetListMissionViewModels(missions);

            if (User.IsInRole(ConstantsHelper.AdminRole))
            {
                model.MissionsToApprove = MissionHelper.GetListMissionViewModels(db.Missions.Where(m => m.Status == Models.FoundryMissionModels.Enums.MissionStatus.InReview).OrderBy(m => m.DateLastUpdated).ToList());
                model.Authors           = AccountHelper.GetAuthorViewModels(db.Users.OrderBy(u => u.UserName).ToList(), db);
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Details(string link)
        {
            //temporary for testing
            var collection = new ViewCollectionViewModel()
            {
                CollectionLink = "superheroes-by-zorbane",
                Description    = "Missions by Zorbane that are inspired by the Marvel Cinematic Universe.  These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME. Missions by Zorbane that are inspired by the Marvel Cinematic Universe.These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME. Missions by Zorbane that are inspired by the Marvel Cinematic Universe.  These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME. Missions by Zorbane that are inspired by the Marvel Cinematic Universe.  These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME. Missions by Zorbane that are inspired by the Marvel Cinematic Universe.These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME. Missions by Zorbane that are inspired by the Marvel Cinematic Universe.  These missions can be played in any order except for the finale mission, UNKNOWN MISSION NAME.",
                Id             = 1,
                ImageLink      = MissionCollectionHelper.GetImageLink("pic.jpg", 1),
                Name           = "Superheroes by Zorbane",
                AuthorTag      = db.Users.FirstOrDefault(u => u.CrypticTag.Equals("Zorbane")).CrypticTag,
                Missions       = new List <ListMissionViewModel>(),
            };

            var missions = new List <Mission>();

            missions.Add(db.Missions.Where(m => m.Name.Equals("The Improbable Bulk")).Single());
            missions.Add(db.Missions.Where(m => m.Name.Equals("Duritanium Man")).Single());

            collection.Missions = MissionHelper.GetListMissionViewModels(missions);

            return(View(collection));
        }
Ejemplo n.º 3
0
        public ActionResult SearchResults(string author, string title, string faction, int?minimumlevel, List <string> tags, int?page)
        {
            //if everything in the model is null also go back
            if (string.IsNullOrWhiteSpace(author) &&
                (faction == null) &&
                (minimumlevel == null) &&
                (tags == null || tags.Count == 0) &&
                string.IsNullOrWhiteSpace(title))
            {
                RedirectToAction("advanced-search");
            }

            int pageNumber = 1;

            if (page != null)
            {
                pageNumber = (int)page;
            }

            //build the query
            var qry = db.Missions.AsQueryable();

            qry = qry.Where(m => m.Status == MissionStatus.Published);

            if (!string.IsNullOrWhiteSpace(title))
            {
                qry = qry.Where(m => m.Name.ToUpper().Contains(title.ToUpper()));
            }
            if (!string.IsNullOrWhiteSpace(faction))
            {
                qry = qry.Where(m => m.Faction.ToString() == faction);
            }

            if (!string.IsNullOrWhiteSpace(author))
            {
                qry = qry.Where(m => m.Author.CrypticTag.ToUpper().Contains(author.ToUpper()));
            }

            if (minimumlevel != null)
            {
                qry = qry.Where(m => m.MinimumLevel <= minimumlevel);
            }

            List <Mission> missions         = qry.OrderByDescending(m => m.DateLastUpdated).ToList();
            List <Mission> filteredMissions = new List <Mission>();

            //filter on the tags
            if (tags != null && tags.Count > 0)
            {
                List <MissionTagType> selectedTags = db.MissionTagTypes.Where(t => tags.Contains(t.TagName)).ToList();

                foreach (var mission in missions)
                {
                    if (mission.Tags.Intersect(selectedTags).Count() == tags.Count)
                    {
                        filteredMissions.Add(mission);
                    }
                }
            }
            else
            {
                filteredMissions = missions;
            }

            var missionCount = filteredMissions.Count();

            missions = filteredMissions.Skip(ConstantsHelper.MissionsPerPage * (pageNumber - 1)).Take(ConstantsHelper.MissionsPerPage).ToList();
            List <ListMissionViewModel> listmissions = MissionHelper.GetListMissionViewModels(missions);

            #region Paging Info

            var totalPages = (missionCount + ConstantsHelper.MissionsPerPage - 1) / ConstantsHelper.MissionsPerPage;

            var pagesCounter = pageNumber - (ConstantsHelper.PagesToShow / 2);

            if (pagesCounter + ConstantsHelper.PagesToShow > totalPages)
            {
                pagesCounter = totalPages - ConstantsHelper.PagesToShow + 1;
            }

            if (pagesCounter < 1)
            {
                pagesCounter = 1;
            }

            ViewBag.CurrentPage  = pageNumber;
            ViewBag.TotalPages   = totalPages;
            ViewBag.MissionCount = missionCount;
            ViewBag.StartPage    = pagesCounter;

            #endregion

            return(View(listmissions));
        }
Ejemplo n.º 4
0
        public ActionResult Search(string q, int?page)
        {
            if (string.IsNullOrEmpty(q))
            {
                return(RedirectToAction("Index", "Home"));
            }

            int pageNumber = 1;

            if (page != null)
            {
                pageNumber = (int)page;
            }


            string upperQuery = q.Trim().ToUpper();

            #region Get Missions
            var missions = db.Missions.Where(m => (m.Author.CrypticTag.ToUpper().Contains(upperQuery) ||
                                                   m.CrypticId.ToUpper().Contains(upperQuery) ||
                                                   m.Description.ToUpper().Contains(upperQuery) ||
                                                   m.Name.ToUpper().Contains(upperQuery)) &&
                                             m.Status == MissionStatus.Published)
                           .OrderByDescending(m => m.DateLastUpdated)
                           .ToList();
            missions = missions.Skip(ConstantsHelper.MissionsPerPage * (pageNumber - 1))
                       .Take(ConstantsHelper.MissionsPerPage).ToList();
            List <ListMissionViewModel> listMissions = MissionHelper.GetListMissionViewModels(missions);
            #endregion

            #region Paging Info

            var missionCount = db.Missions.Where(m => (m.Author.CrypticTag.ToUpper().Contains(upperQuery) ||
                                                       m.CrypticId.ToUpper().Contains(upperQuery) ||
                                                       m.Description.ToUpper().Contains(upperQuery) ||
                                                       m.Name.ToUpper().Contains(upperQuery)) &&
                                                 m.Status == MissionStatus.Published)
                               .Count();

            var totalPages = (missionCount + ConstantsHelper.MissionsPerPage - 1) / ConstantsHelper.MissionsPerPage;

            var pagesCounter = pageNumber - (ConstantsHelper.PagesToShow / 2);
            if (pagesCounter < 1)
            {
                pagesCounter = 1;
            }
            else if (pagesCounter + ConstantsHelper.PagesToShow > totalPages)
            {
                pagesCounter = totalPages - ConstantsHelper.PagesToShow + 1;
            }

            if (pagesCounter == 0)
            {
                pagesCounter = 1;
            }

            ViewBag.Query        = q;
            ViewBag.CurrentPage  = pageNumber;
            ViewBag.TotalPages   = totalPages;
            ViewBag.MissionCount = missionCount;
            ViewBag.StartPage    = pagesCounter; //this is where it starts dispalying clickable page links

            #endregion

            return(View(listMissions));
        }