Example #1
0
        public async Task <IActionResult> Locations(int page = 1)
        {
            Domain.Model.Filter filter = new Domain.Model.Filter(page);

            var locationList = await _eventService.GetPaginatedLocationsListAsync(filter);

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = locationList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            LocationsListViewModel viewModel = new LocationsListViewModel()
            {
                Locations     = locationList.Data,
                PaginateModel = paginateModel,
            };

            return(View(viewModel));
        }
Example #2
0
        public async Task <IActionResult> Index(int page = 1)
        {
            Domain.Model.Filter filter = new Domain.Model.Filter(page);

            var eventList = await _eventService.GetPaginatedListAsync(filter, true);

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = eventList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            EventsListViewModel viewModel = new EventsListViewModel()
            {
                Events             = eventList.Data,
                PaginateModel      = paginateModel,
                CanManageLocations = UserHasPermission(Permission.ManageLocations)
            };

            return(View(viewModel));
        }
Example #3
0
        public async Task <IActionResult> Index(int page = 1)
        {
            Domain.Model.Filter filter = new Domain.Model.Filter(page);

            var triggerList = await _triggerService.GetPaginatedListAsync(filter);

            foreach (var trigger in triggerList.Data)
            {
                trigger.AwardBadgeFilename =
                    _pathResolver.ResolveContentPath(trigger.AwardBadgeFilename);
            }

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = triggerList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            TriggersListViewModel viewModel = new TriggersListViewModel()
            {
                Triggers      = triggerList.Data,
                PaginateModel = paginateModel,
            };

            return(View(viewModel));
        }
Example #4
0
        public async Task <IActionResult> GetRequirementList(string badgeIds,
                                                             string challengeIds,
                                                             string scope,
                                                             string search,
                                                             int page      = 1,
                                                             int?thisBadge = null)
        {
            Domain.Model.Filter filter = new Domain.Model.Filter(page)
            {
                Search = search
            };

            var badgeList = new List <int>();

            if (thisBadge.HasValue)
            {
                badgeList.Add(thisBadge.Value);
            }
            if (!string.IsNullOrWhiteSpace(badgeIds))
            {
                badgeIds = badgeIds.Replace("<", "");
                badgeList.AddRange(badgeIds.Split('>')
                                   .Where(_ => !string.IsNullOrWhiteSpace(_))
                                   .Select(Int32.Parse)
                                   .ToList());
            }
            if (badgeList.Count > 0)
            {
                filter.BadgeIds = badgeList;
            }

            if (!string.IsNullOrWhiteSpace(challengeIds))
            {
                challengeIds        = challengeIds.Replace("<", "");
                filter.ChallengeIds = challengeIds.Split('>')
                                      .Where(_ => !string.IsNullOrWhiteSpace(_))
                                      .Select(Int32.Parse)
                                      .ToList();
            }
            switch (scope)
            {
            case ("System"):
                filter.SystemIds = new List <int>()
                {
                    GetId(ClaimType.SystemId)
                };
                break;

            case ("Branch"):
                filter.BranchIds = new List <int>()
                {
                    GetId(ClaimType.BranchId)
                };
                break;

            case ("Mine"):
                filter.UserIds = new List <int>()
                {
                    GetId(ClaimType.UserId)
                };
                break;

            default:
                break;
            }

            var requirements = await _triggerService.PageRequirementAsync(filter);

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = requirements.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };
            RequirementListViewModel viewModel = new RequirementListViewModel()
            {
                Requirements  = requirements.Data,
                PaginateModel = paginateModel
            };

            foreach (var requirement in requirements.Data)
            {
                if (!string.IsNullOrWhiteSpace(requirement.BadgePath))
                {
                    requirement.BadgePath = _pathResolver.ResolveContentPath(requirement.BadgePath);
                }
            }

            return(PartialView("_RequirementsPartial", viewModel));
        }
Example #5
0
        public async Task <IActionResult> Index(int page         = 1,
                                                string search    = null,
                                                int?branch       = null,
                                                int?location     = null,
                                                int?program      = null,
                                                string StartDate = null,
                                                string EndDate   = null)
        {
            Domain.Model.Filter filter = new Domain.Model.Filter(page)
            {
                Search = search,
            };

            // ignore location if branch has value
            if (branch.HasValue)
            {
                filter.BranchIds = new List <int>()
                {
                    branch.Value
                };
            }
            else if (location.HasValue)
            {
                filter.LocationIds = new List <int?>()
                {
                    location.Value
                };
            }

            if (program.HasValue)
            {
                filter.ProgramIds = new List <int?>()
                {
                    program.Value
                };
            }

            if (!string.IsNullOrWhiteSpace(StartDate))
            {
                filter.StartDate = DateTime.Parse(StartDate).Date;
            }
            if (!string.IsNullOrWhiteSpace(EndDate))
            {
                filter.EndDate = DateTime.Parse(EndDate).Date;
            }

            var eventList = await _eventService.GetPaginatedListAsync(filter);

            PaginateViewModel paginateModel = new PaginateViewModel()
            {
                ItemCount    = eventList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            EventsListViewModel viewModel = new EventsListViewModel()
            {
                Events        = eventList.Data,
                PaginateModel = paginateModel,
                Search        = search,
                ProgramId     = program,
                SystemList    = new SelectList((await _siteService.GetSystemList()), "Id", "Name"),
                LocationList  = new SelectList((await _eventService.GetLocations()), "Id", "Name"),
                ProgramList   = new SelectList((await _siteService.GetProgramList()), "Id", "Name")
            };

            if (branch.HasValue)
            {
                var selectedBranch = await _siteService.GetBranchByIdAsync(branch.Value);

                viewModel.SystemId   = selectedBranch.SystemId;
                viewModel.BranchList = new SelectList(
                    (await _siteService.GetBranches(selectedBranch.SystemId)),
                    "Id", "Name", branch.Value);
            }
            else
            {
                viewModel.BranchList = new SelectList((await _siteService.GetAllBranches()),
                                                      "Id", "Name");
            }
            if (location.HasValue && !branch.HasValue)
            {
                viewModel.LocationId  = location.Value;
                viewModel.UseLocation = true;
            }

            return(View(viewModel));
        }