public static RewardViewModel ToModel(
            Reward reward,
            bool isChecked)
        {
            var model = new RewardViewModel();

            model.RewardId  = reward.ID;
            model.Title     = reward.Title;
            model.IsChecked = isChecked;

            return(model);
        }
예제 #2
0
        public static UsersAndRewardsViewModel CreateModel(User user, List <Reward> rewards)
        {
            var model = new UsersAndRewardsViewModel();

            model.User       = user;
            model.AllRewards = new List <RewardViewModel>();
            foreach (Reward r in rewards)
            {
                var isChecked   = user == null ? false : ContainsReward(r, user.Rewards);
                var rewardModel = RewardViewModel.ToModel(r, isChecked);
                model.AllRewards.Add(rewardModel);
            }

            return(model);
        }