Esempio n. 1
0
        public static UserSubscriptionProductViewModel Convert(UserSubscriptionProduct subscriptionProduct)
        {
            UserSubscriptionProductViewModel model = new UserSubscriptionProductViewModel();

            model.Id = subscriptionProduct.Id;
            if (subscriptionProduct.Product != null)
            {
                model.Product = ProductConverter.Convert(subscriptionProduct.Product);
            }
            if (subscriptionProduct.CustomProduct != null)
            {
                model.CustomProduct = CustomProductConverter.Convert(subscriptionProduct.CustomProduct);
            }
            if (subscriptionProduct.SelectOption != null)
            {
                model.SelectOption = SelectOptionConverter.Convert(subscriptionProduct.SelectOption);
            }
            if (subscriptionProduct.CustomSelectOption != null)
            {
                model.CustomSelectOption = CustomSelectOptionConverter.Convert(subscriptionProduct.CustomSelectOption);
            }
            if (subscriptionProduct.SubscriptionMixCategories != null)
            {
                model.SubscriptionMixCategories = UserSubscriptionMixCategoryConverter.ConvertList(subscriptionProduct.SubscriptionMixCategories);
            }

            return(model);
        }
        public static CustomProductViewModel Convert(CustomProduct product)
        {
            CustomProductViewModel model = new CustomProductViewModel();

            model.Id          = product.Id;
            model.CategoryId  = product.CategoryId;
            model.Name        = product.Name;
            model.Description = product.Description;
            model.Subtitle    = product.Subtitle;
            model.ImageSrc    = product.ImageSrc;
            model.Price       = product?.Price;
            model.IsOnSale    = product.IsOnSale;
            model.IsInStock   = product.IsInStock;
            model.Type        = product.Type;
            model.Category    = CategoryConverter.Convert(product.Category);
            if (product.MixCategories != null)
            {
                model.MixCategories = MixCategoryConverter.ConvertList(product.MixCategories);
            }
            model.Tags = TagConverter.ConvertList(product.Tags);
            if (product.SelectOptions != null)
            {
                model.SelectOptions = CustomSelectOptionConverter.ConvertList(product.SelectOptions);
            }

            return(model);
        }