public async Task <bool> DeleteProduct() { ProductItemViewModel product = null; switch (ProductFilters.Instance.ProductType) { case ProductType.WillBeExpired: product = WillBeExpiredProducts.ElementAt(ItemIndex); break; default: product = Products.ElementAt(ItemIndex); break; } if (product != null) { var arguments = new RealEstateDeleteEstateDto { Id = product.Id, AccountId = App.AccountInfo.Id, IsDelete = true }; IsBusy = true; bool result = await ProductService.UpdateDeleteProduct(arguments); IsBusy = false; if (result) { switch (ProductFilters.Instance.ProductType) { case ProductType.WillBeExpired: WillBeExpiredProducts.RemoveAt(ItemIndex); break; default: Products.RemoveAt(ItemIndex); break; } } ItemIndex = -1; return(result); } return(false); }
public MyProductViewModel() { Title = " My Listing "; LoadMoreProductsCommand = new Command <object>(LoadMoreItems); Products.CollectionChanged += (sender, e) => { HasProduct = Products != null && Products.Any(); }; WillBeExpiredProducts.CollectionChanged += (sender, e) => { HasOnExpringProduct = WillBeExpiredProducts != null && WillBeExpiredProducts.Any(); }; ExpiredProducts.CollectionChanged += (sender, e) => { HasExpiredProduct = ExpiredProducts != null && ExpiredProducts.Any(); }; DeletedProducts.CollectionChanged += (sender, e) => { HasDeletedProduct = DeletedProducts != null && DeletedProducts.Any(); }; }