public ActionResult ReportHtml(int id, int? SelectedChallengeStatus = null, bool? Status = null, string SelectedSuburb = "Suburb", string SearchString = "", int? timeRange = null, int page = 1, int pageSize = 0)
        {
            UserChallengeListModel usersForChallenge = new ChallengesAdminService().GetUserChallenges(id, SelectedChallengeStatus, Status, SelectedSuburb, SearchString, timeRange, page, pageSize);
            ChallengeModel challenge = new ChallengesAdminService().GetChallengeDetails(id);

            ChallengeReportViewModel viewModel = new ChallengeReportViewModel();
            viewModel.UsersList = usersForChallenge;
            viewModel.Challenge = challenge;

            if (timeRange != 0)
                viewModel.DateRange = DateTime.Now.AddDays((double)-timeRange).ToString("dd/MM/yyyy") + " - " + DateTime.Now.ToString("dd/MM/yyyy");
            else
                viewModel.DateRange = ((DateTime)viewModel.Challenge.DateAdded).ToString("dd/MM/yyyy") + " - " + DateTime.Now.ToString("dd/MM/yyyy");

            // viewModel.UsersList.NumChallenges = usersForChallenge.NumChallenges;
            return View("ReportPdf", viewModel);
        }
        public ActionResult Report(int id, int? SelectedOrderBy, int SelectedChallengeStatus = 0, string SelectedSuburb = "Suburb", string SearchString = "", int? timeRange = null, int page = 1, int pageSize = 8)
        {
            LayoutViewModel.ActiveLink = Links.Challenges;

            ChallengeReportViewModel viewModel = new ChallengeReportViewModel();

            var membershipUser = Membership.GetUser();

            bool? pointsClaimed = null;
            switch (SelectedChallengeStatus)
            {
                case 1:
                    pointsClaimed = true;
                    break;
                case 2:
                    pointsClaimed = false;
                    break;
                case 0:
                    pointsClaimed = null;
                    break;
            }

            if (membershipUser != null && membershipUser.ProviderUserKey != null)
            {
                bool InInstance = new ChallengesAdminService().CheckInInstance(id, (Guid)membershipUser.ProviderUserKey);
                if (LayoutViewModel.IsCouncil)
                {

                    if (InInstance)
                    {

                        var usersForChallenge = new ChallengesAdminService().GetUserChallenges(id, SelectedOrderBy, pointsClaimed, SelectedSuburb, SearchString, timeRange, page, pageSize);
                        // viewModel.UsersList.UserChallengeList = usersForChallenge.UserChallengeList;
                        viewModel.UsersList = usersForChallenge;

                        var userId = (Guid)membershipUser.ProviderUserKey;
                        viewModel.ChallengesList = new ChallengesAdminService().GetChallenges(userId, 1, 0, 0, 0, null, null);

                        viewModel.UserId = userId;
                        //  viewModel.User = new UserService().GetUserById(userId);
                        viewModel.ChallengeId = id;
                        viewModel.SelectedSuburb = SelectedSuburb;
                        viewModel.SearchString = SearchString;
                        // viewModel.SelectedChallenge = id;
                        //viewModel.UsersList.NumChallenges = usersForChallenge.NumChallenges;
                        //viewModel.UsersList.NumPages = usersForChallenge.NumPages;
                        //viewModel.UsersList.Page = usersForChallenge.Page;

                        ChallengeModel model = new ChallengesAdminService().GetChallengeDetails(id);

                        viewModel.Challenge = model;

                        ViewModelHelper.SetDefaultsForChallengeReportViewModel(viewModel, membershipUser);
                        // Utils.CopyProperties(usersForChallenge, viewModel.Challenge.UsersChallenge);
                        return View(viewModel);
                    }
                    else return RedirectToAction("Index", "ChallengesAdmin");
                }

                else return RedirectToAction("Index", "Home");

            }
            else return RedirectToAction("Index", "Home");
        }