Exemplo n.º 1
0
        private async void EditAction()
        {
            var vm  = new Contents.City.CityEditVM(Collection.SelectedItem);
            var cnt = new Contents.City.Edit();

            cnt.DataContext = vm;
            var dlg = new ModernDialog
            {
                Title   = "Common dialog",
                Content = cnt
            };

            dlg.Buttons = new Button[] { dlg.OkButton, dlg.CancelButton };
            dlg.ShowDialog();

            if (dlg.DialogResult.Value)
            {
                ModelsShared.Models.city city = new ModelsShared.Models.city {
                    Id = vm.Id, CityCode = vm.CityCode, CityName = vm.CityName, Province = vm.Province, Regency = vm.Regency
                };
                bool isUpdated = await MainVM.CityCollection.Update(Collection.SelectedItem.Id, city);

                if (isUpdated)
                {
                    Collection.SourceView.Refresh();
                    ModernDialog.ShowMessage("Data Is Updated !", "Message Dialog", System.Windows.MessageBoxButton.OK);
                }
            }
        }
Exemplo n.º 2
0
        private async void SaveAction()
        {
            ProgressIsActive = true;
            ModelsShared.Models.city city = new ModelsShared.Models.city {
                CityCode = this.CityCode, CityName = this.CityName, Province = this.Province, Regency = this.Regency
            };
            var res = await Common.ResourcesBase.GetMainWindowViewModel().CityCollection.Post(city);

            MessageBoxButton btn = MessageBoxButton.OK;

            if (res == null)
            {
                ModernDialog.ShowMessage("Data Not Saved !", "Message Dialog", btn);
            }
            else
            {
                var collection = ResourcesBase.GetMainWindowViewModel().CityCollection;
                collection.Source.Add(res);
                collection.SourceView.Refresh();
                var result = ModernDialog.ShowMessage("Data Saved?", "Message Dialog", btn);
                CancelAction();
            }
            ProgressIsActive = false;
        }