Exemplo n.º 1
0
        public static RewardViewModel ToModel(
            Reward reward,
            bool isChecked)
        {
            var model = new RewardViewModel();

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

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

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

            return(model);
        }