private async void SaveAction() { this.ProgressIsActive = true; var item = new ModelsShared.Models.Customer { Address = this.Address, CityID = this.CityID, ContactName = this.ContactName, CustomerType = this.CustomerType, Email = this.Email, Handphone = this.Handphone, Id = this.Id, Name = this.Name, Phone1 = this.Phone1, Phone2 = this.Phone2 }; bool isSaved = await MainVM.CustomerCollection.Add(item); if (isSaved) { MainVM.CustomerCollection.SourceView.Refresh(); ModernDialog.ShowMessage("Data Is Saved !", "Information", System.Windows.MessageBoxButton.OK); this.Clear(); } else { ModernDialog.ShowMessage("Data Not Saved !", "Error", System.Windows.MessageBoxButton.OK); } this.ProgressIsActive = false; }
public CustomerEditVM(ModelsShared.Models.Customer item) { this.MainVM = Common.ResourcesBase.GetMainWindowViewModel(); var t = Common.ResourcesBase.GetEnumCollection <ModelsShared.Models.CustomerType>(); CustomersTypes = (CollectionView)CollectionViewSource.GetDefaultView(t); Task.Factory.StartNew(() => SetItemToEdit(item)); }
private void SetItemToEdit(ModelsShared.Models.Customer item) { this.Address = item.Address; this.ContactName = item.ContactName; this.CustomerType = item.CustomerType; this.Email = item.Email; this.Handphone = item.Handphone; this.Id = item.Id; this.Name = item.Name; this.Phone1 = item.Phone1; this.Phone2 = item.Phone2; this.CityID = item.CityID; }
//private async void RegisterAsyncHandler(HttpResponseMessage response) //{ // if (response.IsSuccessStatusCode) // { // var result = await response.Content.ReadAsAsync<customer>(); // if (result != null) // { // var MainVM = Common.ResourcesBase.GetMainWindowViewModel(); // await MainVM.MessageCollection.Add(new Message { MessageText = string.Format("{0} Is Registered", result.Name) }); // } // } //} private async void EditAction() { var vm = new CustomerEditVM(Collection.SelectedItem); var cnt = new Edit { DataContext = vm }; var dlg = new ModernDialog { Width = 800, Title = "Edit Customer", Content = cnt }; dlg.Buttons = new Button[] { dlg.OkButton, dlg.CancelButton }; dlg.ShowDialog(); if (dlg.MessageBoxResult == System.Windows.MessageBoxResult.OK) { var newitem = new ModelsShared.Models.Customer { Address = vm.Address, ContactName = vm.ContactName, CustomerType = vm.CustomerType, Email = vm.Email, Handphone = vm.Handphone, Id = vm.Id, Name = vm.Name, Phone1 = vm.Phone1, Phone2 = vm.Phone2, CityID = vm.CityID }; var isUpdate = await Collection.Update(Collection.SelectedItem.Id, newitem); if (isUpdate) { Collection.SourceView.Refresh(); ModernDialog.ShowMessage("Data Is Updated !", "Message Dialog", System.Windows.MessageBoxButton.OK); } } }