/// <summary> /// Add new calculator`s result /// </summary> /// <param name="model"></param> /// <returns></returns> public ICalculatorModel AddCalculation(ICalculatorModel model) { _context.Calculations.Add((Calculations)model); _context.SaveChanges(); return(model); }
public StartCalculatorSteps( INavigator navigator, ICalculatorModel calculator) { this.navigator = navigator; this.calculator = calculator; }
public ICalculatorModel AddCalculation(ICalculatorModel model) { if (model.Expression.Equals(string.Empty)) { return(null); } return(model); }
public CalcViewModel() { _model = new CalculatorModel(); this.AddSymbolCommand = new Command<string>(symbol => { //for first button press if (string.IsNullOrEmpty(displayString)) { if (char.IsDigit(symbol[0])) { DisplayString += symbol; return; } else return; } //constraint for input only two numbers and action symbol if (!char.IsDigit(symbol[0]) && symbol != "." && CommandIsFull(displayString)) return; char lastSymbol = GetLastSymbol(displayString); //check point enter if (symbol == "." && !CanAddPoint(displayString, lastSymbol)) return; //check re-enter mathoperator else if (!Char.IsDigit(symbol[0]) && !CanAddMath(displayString, lastSymbol)) { DisplayString = ReplaceLastSymbol(displayString, symbol); return; } DisplayString += symbol; }); this.RemoveLastSymbolCommand = new Command(obj => { if (!string.IsNullOrEmpty(displayString)) this.DisplayString = displayString.Substring(0, displayString.Length - 1); }); this.ClearAllCommand = new Command(obj => { this.DisplayString = string.Empty; }); this.CalculateCommand = new Command(obj => { var result = _model.Calculate(displayString); if (result != null) DisplayString = result.ToString(); }); }
/// <summary> /// Create a new calculator controller /// </summary> /// <param name="model">The model to use with the controller</param> /// <param name="view">The view to use with the controller</param> public CalculatorController(ICalculatorModel model, ICalculatorView view) { Model = model; View = view; //listen View key pressed View.OnKeyPressed += HandleKeyPressed; //listen Model operands & operation Model.OnOperandChanged += HandleOperandChanged; Model.OnOperationChanged += HandleOperationChanged; Model.OnResultComputed += HandleResultComputed; Model.OnCleared += HandleModelCleared; //Clear model at beginning Model.Clear(); }
public CalculatorViewModel(ICalculatorModel calculatorModel) { _calculatorModel = calculatorModel; }
protected override void Context() { _calculatorModel = new CalculatorModel(); }
public CalculatorViewModel(ICalculatorModel calculatorModel) { _calculatorModel = calculatorModel; _display = "0"; }
public CalculatorViewModel() { this._calculatorModel = new CalculatorModel(); _display = "0"; }
protected override void Because() { _calculatorModel = ObjectFactory.GetInstance<ICalculatorModel>(); _viewModel = new CalculatorViewModel(_calculatorModel); base.Because(); }