public RewardsPage() { ViewModel = Resolver.Resolve <RewardsViewModel>(); ViewModel.Navigation = Navigation; BindingContext = ViewModel; InitializeComponent(); }
public RewardsPage(RewardsViewModel viewModel) { ViewModel = viewModel; ViewModel.Navigation = Navigation; BindingContext = ViewModel; InitializeComponent(); }
public ActionResult RewardAcceptance(int id = 1) { RewardsViewModel model = BuildRewardView(id); model.ShowAllocation = true; model.ShowRewards = false; return(View("Reward", model)); }
public RewardsPage(RootPage root) { InitializeComponent(); _model = new RewardsViewModel() { Root = root }; Init(); }
public static RewardsModel ConvertRewardToDomainModel(this RewardsViewModel viewRewardModel) { return(new RewardsModel() { Id = viewRewardModel.Id, Title = viewRewardModel.Title, Description = viewRewardModel.Description, }); }
public IHttpActionResult RetrieveInitialData() { var viewModel = new RewardsViewModel { Users = DataContainerSingleton.LstUsers, Comments = DataContainerSingleton.LstComments }; return(Ok(viewModel)); }
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); }
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)); }
public override void Init(object obj) { App.Configuration.Initial(this); NavigationPage.SetHasNavigationBar(this, false); _model = new RewardsViewModel() { Root = (RootPage)obj }; BindingContext = _model; _model.LoadAsync(); }
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)); }
// 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)); }
public RewardsPage() { InitializeComponent(); BindingContext = vm = new RewardsViewModel(); }
public IActionResult Edit(RewardsViewModel reward) { usersAndRewardsStorage.UpdateReward(reward.ConvertRewardToDomainModel()); return(RedirectToAction(nameof(Index))); }
public IActionResult Edit(int?id) { RewardsViewModel rewardEdit = usersAndRewardsStorage.GetRewardsList().FirstOrDefault(td => td.Id == id.Value).ConvertRewardToViewModel(); return(View("AddOrEdit", rewardEdit)); }