public static AwardViewModel GetViewModel(Award award, IEnumerable <Award> userAwards)
        {
            var model = new AwardViewModel();

            model.Id          = award.Id;
            model.Title       = award.Title;
            model.Description = award.Description;
            model.Checked     = userAwards.Any(r => r.Id == award.Id);
            return(model);
        }
예제 #2
0
        public static UserViewModel GetViewModel(User user, IEnumerable <Award> awards)
        {
            var userModel = new UserViewModel();

            userModel.Id         = user.Id;
            userModel.FirstName  = user.FirstName;
            userModel.LastName   = user.LastName;
            userModel.Birthdate  = user.BirthDate;
            userModel.Age        = user.UserAge;
            userModel.UserAwards = user.GetAwards();

            var rewards = new List <AwardViewModel>();

            foreach (var award in awards)
            {
                rewards.Add(AwardViewModel.GetViewModel(award, user.GetAwards()));
            }

            userModel.AvailableRewards = rewards.ToList();

            return(userModel);
        }