コード例 #1
0
        private void AddPizza(object obj)
        {
            var addDialogVM = new AddEditPizzaDialogViewModel(null, _connectionName);
            var dialog      = new AddEditPizzaDialog(addDialogVM);

            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                try
                {
                    addDialogVM.Pizza.PizzaTypeId = addDialogVM.SelectedPizzaType.PizzaTypeId;
                    new PizzaService(_connectionName).Create(addDialogVM.Pizza);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    NLog.LogManager.GetCurrentClassLogger().Error(e, "Ошибка добавления пиццы");
                }
                RefreshPizzas();
            }
        }
コード例 #2
0
        private void EditPizza(object obj)
        {
            var editDialogVM = new AddEditPizzaDialogViewModel(SelectedPizza, _connectionName);
            var dialog       = new AddEditPizzaDialog(editDialogVM);

            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                //Set null to avoid changes conflict
                editDialogVM.Pizza.PizzaType = null;
                editDialogVM.Pizza.Spot      = null;
                try
                {
                    new PizzaService(_connectionName).Update(editDialogVM.Pizza);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    NLog.LogManager.GetCurrentClassLogger().Error(e, "Ошибка изменения пиццы");
                }
                RefreshPizzas();
            }
        }