Exemplo n.º 1
0
        private async void DeleteSubCat(SubCatViewModel item)
        {
            try
            {
                await _service.DeleteSubCatAsync(item.Id);

                SubCats.Remove(SelectedSubCat);
                SelectedSubCat = null;
            }
            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }
Exemplo n.º 2
0
        private async void LoadProductAsync(SubCatViewModel subcatDto)
        {
            if (subcatDto is null)
            {
                return;
            }

            try
            {
                SelectedMainCatName = subcatDto.Name;
                Products            = new ObservableCollection <ProductViewModel>((await _service.LoadProductAsync(subcatDto.Id))
                                                                                  .Select(item => (ProductViewModel)item));
            }
            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }
Exemplo n.º 3
0
        private async void AddSubCat()
        {
            var newItem = new SubCatViewModel
            {
                Name      = "New Item",
                MainCatId = SelectedMainCat.Id
            };

            var itemDto = (SubCatDto)newItem;

            try
            {
                await _service.CreateSubCatAsync(itemDto); // ERROR

                newItem.Id = itemDto.Id;
                SubCats.Add(newItem);
                SelectedSubCat = newItem;
            }

            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }
Exemplo n.º 4
0
 public void CopyFrom(SubCatViewModel rhs)
 {
     Id        = rhs.Id;
     Name      = rhs.Name;
     MainCatId = rhs.MainCatId;
 }