Exemple #1
0
        public SampleRuleViewModel()
        {
            m_data = SimpleXamlSerializer.ToXaml(SampleRules.GetOrCreateSampleRule());

            CopyCommand           = new RelayCommand(() => Clipboard.SetText(Data), () => !string.IsNullOrEmpty(Data));
            PasteCommand          = new RelayCommand(() => Data = Clipboard.GetText(), Clipboard.ContainsText);
            LoadDefaultCommand    = new RelayCommand(() => LoadDefault());
            ToggleEditModeCommand = new RelayCommand(() => IsInEditMode = !IsInEditMode);
            SetEditModeCommand    = new RelayCommand <bool>(x => IsInEditMode = x);
            ApplyEditTextCommand  = new RelayCommand(() => ApplyEditText());
            ApplyGraphCommand     = new RelayCommand(() => ApplyGraph(), () => IsGraphChanged);
            RevertGraphCommand    = new RelayCommand(() => Designer = null, () => IsGraphChanged);
            SaveCommand           = new RelayCommand(() => Save(), () => IsModified);
        }
        public async Task ProcessOrderAsync()
        {
            var rule = RuleBuilder.CreateRuleImp(SampleRules.GetOrCreateSampleRule());

            if (rule == null)
            {
                throw new InvalidOperationException("Rule object is not defined.");
            }
            var context = new OrderDiscountContext(Order.Model);
            await context.ExecuteAsync(rule);

            Discounts = context.GetOrderDiscounts();
            Total     = DiscountLogic.GetOrderTotalAmount(Order.Model, Discounts);
            LogInfo("Order has been processed successfully.");
        }
Exemple #3
0
 private void LoadDefault()
 {
     Data = SimpleXamlSerializer.ToXaml(SampleRules.CreateSampleRule());
     LogInfo("Loaded default sample data.");
 }