コード例 #1
0
 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();
 }
コード例 #2
0
 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();
 }