public ActionResult Index(TaxCalculateViewModel model) { if (ModelState.IsValid) { var taxRate = DocumentSession.Load <TaxRate>(model.SelectedYear); model.Result = _calculateService.Calculate(taxRate, model.TaxableIncome.Value); } else { ShowErrorMessage("Please input valid data"); } var list = DocumentSession.Query <TaxRate>() .OrderByDescending(r => r.Year) .ToArray() .Select(r => new SelectListItem { Text = r.Description, Value = r.Id.ToString(), }); ViewBag.TaxRatesList = list; return(View(model)); }
public IActionResult Calculate([FromBody] Input input) { Result response = new Result(); // Validate the user input response.error = _validationService.ValidateExpression(input.sum); if (string.IsNullOrEmpty(response.error)) { // Parse the math expression from raw string LinkedList <Token> tokenList = _parser.ExpressionParser(input.sum, out int maxDepth); // Do calculation and return result response.result = string.Empty; if (tokenList.Count > 0) { response.result = _calculateService.Calculate(tokenList, maxDepth).ToString(); } return(Ok(response)); } else { return(BadRequest(response)); } }
public IActionResult Calculate([FromBody] CalculateFormulaRequest calculateFormulaRequest) { try { var formulaEvaluatorResponse = calculateService.Calculate(calculateFormulaRequest); var apiResponseWrapper = new ApiResponseWrapper <FormulaResponse> { Data = new FormulaResponse { Value = formulaEvaluatorResponse.Value }, Message = formulaEvaluatorResponse.Message, ErrorCount = formulaEvaluatorResponse.IsSuccess ? 0 : 1, Errors = formulaEvaluatorResponse.IsSuccess ? new List <string>() : new List <string> { formulaEvaluatorResponse.Message } }; return(formulaEvaluatorResponse.IsSuccess ? Ok(apiResponseWrapper) : BadRequest(apiResponseWrapper)); } catch (Exception ex) { logger.LogError(ex, "{Message}", ex.Message); return(BadRequest(new ApiResponseWrapper <WebServiceResponse> { Message = ex.Message, Status = ApiConstants.FailedResult })); } }
private void CalculateGameOver(GamePlay gamePlay) { foreach (ITile tile in gamePlay.PlacedTiles) { if (tile is Church && tile.CenterFigure != null) { var churchTile = (Church)tile; calculateService.Calculate(tile, true, ref gamePlay.Players); } for (int i = 0; i < 4; i++) { if (tile.Directions[i].Figure != null && !(tile.Directions[i].Landscape == Landscape.Field)) { calculateService.Calculate(tile, true, ref gamePlay.Players); } } } }
public void Test_Case_1() { // "1 + 1" LinkedList <Token> testLinkedList = new LinkedList <Token>(); testLinkedList.AddLast(new Token() { Depth = 0, Number = 1, Operation = Operation.Number }); testLinkedList.AddLast(new Token() { Depth = 0, Number = 0, Operation = Operation.Add }); testLinkedList.AddLast(new Token() { Depth = 0, Number = 1, Operation = Operation.Number }); double result = _calculateService.Calculate(testLinkedList, 0); Assert.AreEqual(2, result); }
private async void Button_Click_1(object sender, RoutedEventArgs e) { Assembly ass = Assembly.GetExecutingAssembly(); string path = System.IO.Path.GetDirectoryName(ass.Location); DirectoryInfo di = new DirectoryInfo(path + "\\files"); Dictionary <string, string> l = new Dictionary <string, string>(); var result = await _calculateService.Calculate(di); listaWynikow.ItemsSource = result; MessageBox.Show("pomyślnie"); }
public async Task Handle(ReceiveContext <CalculateCommand> context, CancellationToken cancellationToken) { var result = _calculateService.Calculate(context.Message.Left, context.Message.Right); await context.PublishAsync(new ResultCalculatedEvent(result), CancellationToken.None); }
public void CalculateAddition(double firstNumber, double secondNumber) { var result = _calculateService.Calculate(firstNumber, secondNumber); Assert.AreEqual(10, result); }
public int GetCalculateResult() { return(_calculateService.Calculate(_values.ToArray())); }