private void EditCakeDialogClosingEventHandler(object sender, DialogClosingEventArgs eventArgs) { if (eventArgs.Parameter is bool parameter && parameter == false) { return; } using (var db = new CAKESTOREEntities()) { var cake = db.CAKEs.Find(this.SelectedCake.CAKE_ID); var modifiedCake = this._detailDialogViewModel.SelectedCake; cake.CAKE_NAME = modifiedCake.CAKE_NAME; cake.CAKE_TYPE = this._detailDialogViewModel.CakeCategories[this._detailDialogViewModel.SelectedIndex].TYPE_ID; cake.PRICE = modifiedCake.PRICE; cake.IMAGE = modifiedCake.IMAGE; cake.REMAINING_AMOUNT = modifiedCake.REMAINING_AMOUNT; cake.DESCRIPTION = modifiedCake.DESCRIPTION; db.SaveChanges(); this.SelectedCake = cake; }; MainWindowViewModel.Instance.GetAutocompleteSource(); }
private async void ExecuteAddCakeToOrderAsync(object obj) { CAKE cake = obj as CAKE; this._addCakeToCakesInOrderViewModel = new AddCakeToCakesInOrderViewModel(cake); var view = new AddCakeToCakesInOrderDialogControl { DataContext = this._addCakeToCakesInOrderViewModel }; var result = await DialogHost.Show(view, MainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, AddCaketoOrderClosingEventHandle); Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
public AddCakeToCakesInOrderViewModel(CAKE cake) { //Kieểm tra Cake này có trong order chưa var CakeInOrderNow = CreateOrderScreenViewModel.Instance.GetAllCakeInOrderNow(); Cake = cake; CakeInOrder = CakeInOrderNow.FirstOrDefault(item => item.CAKE_ID == cake.CAKE_ID); if (CakeInOrder == null) { //nếu chưa có thì tạo new và gán thong tin cake cơ bản CakeInOrder = new CAKE_IN_ORDERS(); CakeInOrder.CAKE_ID = cake.CAKE_ID; CakeInOrder.CAKE = Cake; CakeInOrder.NUMBER = 1; } }