Example #1
0
        public CatalogItemVM(Product model)
        {
            Model = model;

            Id = model.Id;

            if (!model.ImageUrls.IsNullOrEmpty())
            {
                var image = model.ImageUrls.First();
                ImageUrl = image.SmallUrl;
            }

            Name = model.Name;

            Price = FormatPrice(model);

            MaxPrice = FormatMaxPrice(model);

            OldPrice = FormatOldPrice(model);

            if (!model.Badges.IsNullOrEmpty())
            {
                Badges = model.Badges.Select(SetupBadgeItem).ToList();
            }

            Marked = model.IsMarked;

            StateName = model.State?.Name;

            MarkEnabled = ConfigService.Config.MarkedEnabled;

            BasketBlockViewModel = VmService.LoadItemBasketVm();

            if (BasketBlockViewModel is IMvxViewModel <IMvxBundle> parameterVM)
            {
                parameterVM.Prepare(new ProductCardBundle(Model, Base.Core.Models.Navigation.NavigationType.InsideScreen));
            }
            else
            {
                BasketBlockViewModel?.Init(new ProductCardBundle(Model, Base.Core.Models.Navigation.NavigationType.InsideScreen));
            }

            if (BasketBlockViewModel is IActionCommandViewModel actionCommandVM)
            {
                HasAction     = true;
                ActionCommand = actionCommandVM.ActionCommand;
                ActionText    = actionCommandVM.ActionText;
            }
        }