Beispiel #1
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);
        }