Exemplo n.º 1
0
        private async void DeleteMainCat(MainCatViewModel list)
        {
            try
            {
                await _service.DeleteMainCatAsync(list.Id);

                MainCats.Remove(SelectedMainCat);
                SelectedMainCat = null;
            }
            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }
Exemplo n.º 2
0
        private async void LoadSubCatsAsync(MainCatViewModel maincat)
        {
            if (maincat is null)
            {
                SubCats = null; // itt lehet productot is nullolni kéne
                return;
            }

            try
            {
                SelectedMainCatName = maincat.Name;
                SubCats             = new ObservableCollection <SubCatViewModel>((await _service.LoadSubCatsAsync(maincat.Id))
                                                                                 .Select(item => (SubCatViewModel)item));
            }
            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }
Exemplo n.º 3
0
        private async void AddMainCat()
        {
            var newList = new MainCatViewModel
            {
                Name = "New MainCat"
            };

            var listDto = (MainCatDto)newList;

            try
            {
                await _service.CreateMainCatAsync(listDto);

                newList.Id = listDto.Id;
                MainCats.Add(newList);
                SelectedMainCat = newList;
            }

            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
        }