public static SubscriptionsViewModel ToModel(
            Subscription subscription,
            bool isChecked)
        {
            var model = new SubscriptionsViewModel
            {
                SubscriptionId = subscription.SubscriptionId,
                NameService    = subscription.NameService,
                Description    = subscription.Description,
                IsChecked      = isChecked
            };

            return(model);
        }
Esempio n. 2
0
        public static UsersViewModel CreateModel(User user, List <Subscription> subscriptions)
        {
            var model = new UsersViewModel
            {
                User             = user,
                AllSubscriptions = new List <SubscriptionsViewModel>()
            };

            foreach (var item in subscriptions)
            {
                var isChecked         = user == null ? false : user.Subscriptions.Contains(item);
                var subscriptionModel = SubscriptionsViewModel.ToModel(item, isChecked);
                model.AllSubscriptions.Add(subscriptionModel);
            }

            return(model);
        }