private async void RefreshAction(object obj)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;

                SourceView.Clear();
                var results = await LayananServices.GetItemsAsync();

                var group = results.GroupBy(O => O.Kategori.Nama);
                Kategories.Clear();
                foreach (var d in group)
                {
                    Kategories.Add(d.Key);
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        private void addkategori_LostFocus(object sender, RoutedEventArgs e)
        {
            var textBox = (TextBox)sender;

            if (textBox.Text != string.Empty)
            {
                var text = textBox.Text.Trim().ToUpper();
                using (var db = new OcphDbContext())
                {
                    var newCat = new Kategori {
                        Name = text
                    };
                    newCat.Id = db.Categories.InsertAndGetLastID(newCat);
                    if (newCat.Id > 0)
                    {
                        Kategories.Add(newCat);
                    }
                }
                textBox.Text = string.Empty;
                KategoriesView.Refresh();
            }
        }