/// <summary> /// Performs the operation of adding the numbers typed into the view by /// the user. /// </summary> /// <remarks> /// When this method is called, first, the inputs made by the user are validated. /// <para /> /// If validation fails, then an error message box is displayed to the /// user, and the input focus is set to the text box containing the /// first value in the series. /// <para /> /// Otherwise, the operation is performed and then the view is updated /// with the results. /// </remarks> private void Add() { try { Validate(); _service.CalculateTotal( _model, new List <string> { _view.FirstValue, _view.SecondValue, _view.ThirdValue }.ConvertAll(SafeGetNumber) ); _view.TotalValue = Convert.ToString( _model.Total, CultureInfo.InvariantCulture ); _view.RunningTotalValue = Convert.ToString( _model.RunningTotal, CultureInfo.InvariantCulture ); _view.TotalValueTextBox.Focus(); } catch (InvalidOperationException e) { MessageBox.Show( _view, e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1 ); _view.FirstValueTextBox.Focus(); } }