Exemplo n.º 1
0
        async Task ExecuteRefreshCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var productImages = await _service.GetProductImageByProductId(_item.Id);

                ProductImages.Clear();
                foreach (var pr in productImages)
                {
                    ProductImages.Add(pr);
                }
            }
            catch (Exception ex)
            {
                Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        internal void Apply(ImageAddedEvent @event)
        {
            var image = new ProductImage();

            image.Route(@event);
            ProductImages.Add(image);
        }
Exemplo n.º 3
0
        public virtual void AddProductImage(Image image, int position)
        {
            var productImage = new ProductImage
            {
                Image    = image,
                Position = position,
                Product  = this
            };

            image.ProductImages.Add(productImage);
            ProductImages.Add(productImage);
        }
Exemplo n.º 4
0
 public Product SetProductImages(List <string> images)
 {
     if (!images.IsNullOrZero())
     {
         if (ProductImages.IsNullOrZero())
         {
             ProductImages = new List <ProductImage>();
         }
         images.ForEach(item =>
         {
             ProductImages.Add(new ProductImage().Create(Id, item));
         });
     }
     return(this);
 }
Exemplo n.º 5
0
 public Product UpdateProductImages(List <ProductImageModel> productImages, List <string> images)
 {
     if (!productImages.IsNullOrZero())
     {
         if (ProductImages.IsNullOrZero())
         {
             ProductImages = new List <ProductImage>();
         }
         var savedImagesList   = productImages.Select(p => p.ImageName).ToList();
         var removedImagesList = ProductImages.Where(p => !savedImagesList.Contains(p.ImageName)).ToList();
         removedImagesList.ForEach(item =>
         {
             ProductImages.Remove(item);
         });
         if (!images.IsNullOrZero())
         {
             images.ForEach(item =>
             {
                 ProductImages.Add(new ProductImage().Create(Id, item));
             });
         }
     }
     return(this);
 }