Пример #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})");
            }
        }
Пример #2
0
        private async void SaveSubCatEdit()
        {
            try
            {
                SelectedSubCat.CopyFrom(EditableSubCat);
                await _service.UpdateSubCatAsync((SubCatDto)SelectedSubCat);

                if (SelectedSubCat.MainCatId != SelectedMainCat.Id)
                {
                    SubCats.Remove(SelectedSubCat);
                    SelectedSubCat = null;
                }
            }
            catch (Exception ex) when(ex is NetworkException || ex is HttpRequestException)
            {
                OnMessageApplication($"Unexpected error occured! ({ex.Message})");
            }
            FinishingSubCatEdit?.Invoke(this, EventArgs.Empty);
        }