private async void OnRemoveCategoryExecute(int?id)
        {
            try
            {
                if (!id.HasValue)
                {
                    return;
                }
                var result = await _dialogService.AskQuestionAsync("¿Estas seguro de querer eliminar esta categoria?", "Elimiar Categoria");

                if (result == MessageDialogResult.Negative)
                {
                    return;
                }

                var httpResponse = await ShowProgressAsync(async() => await _categoryRepository.DeleteCategoryAsync(id.Value));

                if (httpResponse.IsSuccess)
                {
                    var category = ProductCategories.Single(x => x.Id == httpResponse.Value);
                    ProductCategories.Remove(category);
                }
                else
                {
                    await _dialogService.ShowMessageAsync(httpResponse.Message, httpResponse.Title);
                }
            }
            catch (Exception ex)
            {
                _logService.Write(ex);
                await _dialogService.ShowMessageAsync(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void RemoveCategory(Guid categoryId)
        {
            var removedCategory =
                ProductCategories.SingleOrDefault(g => g.CategoryId == categoryId && g.ProductId == Id);

            if (removedCategory == null)
            {
                throw new NotFoundException(nameof(categoryId), categoryId);
            }
            ProductCategories.Remove(removedCategory);
        }
Ejemplo n.º 3
0
        public virtual void RemoveCategory(Category category)
        {
            var productCategory = ProductCategories
                                  .Where(pc => pc.Category.Id == category.Id)
                                  .SingleOrDefault();

            if (productCategory == null)
            {
                return;
            }
            ProductCategories.Remove(productCategory);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Delete a product category
 /// </summary>
 public void DeleteProductCategory(ProductCategory category)
 {
     ProductCategories.Remove(category);
     db.ProductCategory.Remove(category);
     db.SaveChanges();
 }