private string BuildQueryString(PackageCostModel model) { NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty); queryString[nameof(PackageDto.Height)] = model.Height.ToString(CultureInfo.InvariantCulture); queryString[nameof(PackageDto.Width)] = model.Width.ToString(CultureInfo.InvariantCulture); queryString[nameof(PackageDto.Length)] = model.Length.ToString(CultureInfo.InvariantCulture); queryString[nameof(PackageDto.Weight)] = model.Weight.ToString(CultureInfo.InvariantCulture); return queryString.ToString(); }
public async Task<ActionResult> Cost(PackageCostModel model) { if (ModelState.IsValid) { string query = BuildQueryString(model); var response = await client.GetAsync($"packages/cost?{query}"); if (response.IsSuccessStatusCode) { var cost = await response.Content.ReadAsAsync<decimal>(); ViewBag.Cost = cost; return View(model); } } return View(); }