コード例 #1
0
 public RewardsPage()
 {
     ViewModel            = Resolver.Resolve <RewardsViewModel>();
     ViewModel.Navigation = Navigation;
     BindingContext       = ViewModel;
     InitializeComponent();
 }
コード例 #2
0
 public RewardsPage(RewardsViewModel viewModel)
 {
     ViewModel            = viewModel;
     ViewModel.Navigation = Navigation;
     BindingContext       = ViewModel;
     InitializeComponent();
 }
コード例 #3
0
        public ActionResult RewardAcceptance(int id = 1)
        {
            RewardsViewModel model = BuildRewardView(id);

            model.ShowAllocation = true;
            model.ShowRewards    = false;
            return(View("Reward", model));
        }
コード例 #4
0
 public RewardsPage(RootPage root)
 {
     InitializeComponent();
     _model = new RewardsViewModel()
     {
         Root = root
     };
     Init();
 }
コード例 #5
0
 public static RewardsModel ConvertRewardToDomainModel(this RewardsViewModel viewRewardModel)
 {
     return(new RewardsModel()
     {
         Id = viewRewardModel.Id,
         Title = viewRewardModel.Title,
         Description = viewRewardModel.Description,
     });
 }
コード例 #6
0
        public IHttpActionResult RetrieveInitialData()
        {
            var viewModel = new RewardsViewModel
            {
                Users    = DataContainerSingleton.LstUsers,
                Comments = DataContainerSingleton.LstComments
            };

            return(Ok(viewModel));
        }
コード例 #7
0
        private RewardsViewModel BuildRewardView(int id)
        {
            string current_user = User.Identity.Name;
            var    testchild    = BL.GetChildAndRewardsForId(id);

            var model          = new RewardsViewModel();
            var rewardsAwarded = BL.GetRewardAwardedForId(id).OrderByDescending(a => a.RewardReceivedDate).ToList();
            List <RewardAwardedVM> rewardsAwardedVM = BuildRewardsAwardedVM(rewardsAwarded);

            model.RewardsAwardedVM = rewardsAwardedVM;

            var goals = BL.GetGoals().Where(a => a.ParentUser == current_user).ToList();

            var vmlist = new List <ChildRewardVM>();

            foreach (var x in goals)
            {
                var rewardallocated = testchild.ChildRewards.Where(a => a.GoalId == x.GoalId).FirstOrDefault();
                int pointsallocated = 0;
                var cr = new ChildRewardVM();
                if (rewardallocated != null)
                {
                    cr.RewardComplete = rewardallocated.RewardComplete;
                    cr.WantReward     = rewardallocated.RewardRequested;
                    cr.GiveReward     = rewardallocated.RewardComplete;
                    pointsallocated   = rewardallocated.PointsAllocated;
                }

                cr.ChildId            = id;
                cr.Administrator      = true; // temporary as will do another way
                cr.GoalCompletePoints = x.GoalPointsRequired;
                cr.GoalName           = x.GoalName;
                cr.GoalId             = x.GoalId;
                cr.GoalPoints         = pointsallocated; // fetch from rewards
                cr.GoalPointsOriginal = pointsallocated; // fetch from rewards


                if (pointsallocated == x.GoalPointsRequired)
                {
                    cr.SliderVisible = false;
                }
                else
                {
                    cr.SliderVisible = true;
                }
                vmlist.Add(cr);
            }
            model.ChildRewardsVM  = vmlist;
            ViewBag.Child         = BL.GetChildForId(id);
            ViewBag.Administrator = true;
            model.Administrator   = true;
            model.UserLevel       = false;
            model.Child           = BL.GetChildForId(id);
            return(model);
        }
コード例 #8
0
        public ActionResult Reward(int id = 1)
        {
            string current_user = User.Identity.Name; // note, might need to change when not a logged in User
            // var testreward = BL.GetChildRewardForId(1, 2);
            var testchild = BL.GetChildAndRewardsForId(id);
            var model     = new RewardsViewModel();

            model.ShowAllocation = true;
            model.ShowRewards    = false;
            var rewardsAwarded = BL.GetRewardAwardedForId(id);
            List <RewardAwardedVM> rewardsAwardedVM = BuildRewardsAwardedVM(rewardsAwarded);

            model.RewardsAwardedVM = rewardsAwardedVM;

            var goals  = BL.GetGoals().Where(a => a.ParentUser == current_user).ToList();
            var vmlist = new List <ChildRewardVM>();

            foreach (var x  in goals)
            {
                var rewardallocated = testchild.ChildRewards.Where(a => a.GoalId == x.GoalId && a.RewardComplete == false).FirstOrDefault();
                int pointsallocated = 0;

                var cr = new ChildRewardVM();
                if (rewardallocated != null)
                {
                    pointsallocated   = rewardallocated.PointsAllocated;
                    cr.WantReward     = rewardallocated.RewardRequested;
                    cr.RewardComplete = rewardallocated.RewardComplete;
                }

                cr.ChildId            = id;
                cr.GoalCompletePoints = x.GoalPointsRequired;
                cr.GoalName           = x.GoalName;
                cr.GoalId             = x.GoalId;
                cr.GoalPoints         = pointsallocated; // fetch from rewards
                cr.GoalPointsOriginal = pointsallocated; // fetch from rewards

                if (pointsallocated == x.GoalPointsRequired)
                {
                    cr.SliderVisible = false;
                }
                else
                {
                    cr.SliderVisible = true;
                }
                vmlist.Add(cr);
            }
            model.ChildRewardsVM = vmlist;
            ViewBag.Child        = BL.GetChildForId(id);
            model.Child          = BL.GetChildForId(id);
            model.Administrator  = false;
            model.UserLevel      = true;
            return(View(model));
        }
コード例 #9
0
 public override void Init(object obj)
 {
     App.Configuration.Initial(this);
     NavigationPage.SetHasNavigationBar(this, false);
     _model = new RewardsViewModel()
     {
         Root = (RootPage)obj
     };
     BindingContext = _model;
     _model.LoadAsync();
 }
コード例 #10
0
        public IActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction(nameof(Index)));
            }

            RewardsViewModel rewardRemove = usersAndRewardsStorage.GetRewardsList().FirstOrDefault(td => td.Id == id.Value).ConvertRewardToViewModel();

            if (rewardRemove == null)
            {
                return(NotFound());
            }

            return(View(rewardRemove));
        }
コード例 #11
0
        // GET: Rewards
        public ActionResult Index()
        {
            //var rewards = db.Rewards.Where(r => r.RewardCodes.Any(rc => rc.IsUsed == false));
            //return View(rewards.ToList());

            Session["rewardCodeId"] = null;

            var rewards = db.Rewards.Where(r => r.RewardCodes.Any(rc => rc.IsUsed == false));
            var user    = db.ApplicationUsers.Find(User.Identity.GetUserId());

            RewardsViewModel viewModel = new RewardsViewModel();

            viewModel.Rewards         = new List <Reward>();
            viewModel.Rewards         = rewards.ToList();
            viewModel.ApplicationUser = user;

            return(View(viewModel));
        }
コード例 #12
0
 public RewardsPage()
 {
     InitializeComponent();
     BindingContext = vm = new RewardsViewModel();
 }
コード例 #13
0
 public IActionResult Edit(RewardsViewModel reward)
 {
     usersAndRewardsStorage.UpdateReward(reward.ConvertRewardToDomainModel());
     return(RedirectToAction(nameof(Index)));
 }
コード例 #14
0
        public IActionResult Edit(int?id)
        {
            RewardsViewModel rewardEdit = usersAndRewardsStorage.GetRewardsList().FirstOrDefault(td => td.Id == id.Value).ConvertRewardToViewModel();

            return(View("AddOrEdit", rewardEdit));
        }