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; } }
internal void Apply(ImageAddedEvent @event) { var image = new ProductImage(); image.Route(@event); ProductImages.Add(image); }
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); }
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); }
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); }