Exemple #1
0
        private async void EditAction()
        {
            var vm  = new Contents.Port.PortEditVM(Collection.SelectedItem);
            var cnt = new Contents.Port.Edit();

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

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

            if (dlg.DialogResult.HasValue)
            {
                ModelsShared.Models.port port = new ModelsShared.Models.port
                {
                    CityID   = vm.CityID,
                    Code     = vm.Code,
                    PortType = vm.PortType,
                    Id       = vm.Id,
                    Name     = vm.Name,
                    CityName = MainVm.CityCollection.Source.Where(O => O.Id == vm.CityID).FirstOrDefault().CityName
                };
                var isUpdated = await Collection.Update(port.Id, port);

                if (isUpdated != default(ModelsShared.Models.port))
                {
                    Collection.SourceView.Refresh();
                    ModernDialog.ShowMessage("Data Is Updated !", "Message Dialog", System.Windows.MessageBoxButton.OK);
                }
            }
        }
        private async void SaveAction()
        {
            ModelsShared.Models.port port = new ModelsShared.Models.port
            {
                CityID   = this.CityID,
                Code     = this.Code,
                PortType = this.PortType,
                Id       = this.Id,
                Name     = this.Name,
                CityName = CityCollection.SelectedItem.CityName
            };
            var res = await Collection.Add(port);

            if (res != null)
            {
                MessageBoxButton btn = MessageBoxButton.OK;
                var result           = ModernDialog.ShowMessage("Data Saved?", "Message Dialog", btn);
                Cancel.Execute(null);
            }
        }