public void ShippingCosts_DefaultConstructor() { CalculationInputs inputs = new CalculationInputs(); Assert.IsTrue(inputs.Weight == 0m); Assert.IsTrue(inputs.ZipCode == "Unspecified"); }
public decimal DoCalculation(CalculationInputs inputs) { var isValidInput = Decimal.TryParse(inputs.InputValueOne, out var firstValue); isValidInput = Decimal.TryParse(inputs.InputValueTwo, out var secondValue); isValidInput = Decimal.TryParse(inputs.InputValueThree, out var thirdValue); isValidInput = Decimal.TryParse(inputs.InputValueFour, out var fourthValue); if (isValidInput) { return((((firstValue) * (secondValue)) + thirdValue) / fourthValue); } else if (isValidInput && Decimal.Compare(fourthValue, 0) == 0) { return(0); } return(0); }
public async Task <IActionResult> Index(CalculationInputs numberInput) { using (var client = new HttpClient()) { var myContent = JsonConvert.SerializeObject(numberInput); var baseURI = @"http://localhost:60110/"; client.BaseAddress = new Uri(baseURI); client.DefaultRequestHeaders.Clear(); var data = new StringContent(myContent, Encoding.UTF8, "application/json"); var response = await client.PostAsync(PostURI, data); if (response.IsSuccessStatusCode) { ViewBag.UserMessage = $"Your Result is: {response.Content.ReadAsStringAsync().Result}"; } } ModelState.Clear(); return(View()); }
public string Post([FromBody] CalculationInputs model) { return(this._CalculationService.DoCalculation(model).ToString()); }