Guest User

Untitled

a guest
Sep 27th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. public ActionResult ImportListByVesselVoyage()
  2. {
  3. return View();
  4. }
  5.  
  6. [HttpPost]
  7. public ActionResult ImportListByVesselVoyage(WebTrackParam param)
  8. {
  9. client = new HttpClient();
  10. List<ImportListByVesselVoyageGetILBV> appMenu = new List<ImportListByVesselVoyageGetILBV>();
  11.  
  12. client.BaseAddress = new Uri(url);
  13. MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
  14. client.DefaultRequestHeaders.Accept.Add(contentType);
  15. try
  16. {
  17.  
  18. HttpResponseMessage response = client.GetAsync(string.Format("/Services/WebTrack.svc/ImportListByVesselVoyageGetILBVJSONData/{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}", "VR", "2018", param.reg, " ", " ", "A", "A", "S,Y,D", "F,L,E,T", "ITTEST", "2")).Result;
  19.  
  20. if (response.IsSuccessStatusCode)
  21. {
  22. var stringData = response.Content.ReadAsStringAsync().Result;
  23. JObject result = JObject.Parse(stringData);
  24. var appMenuarray = result["ImportListByVesselVoyageGetILBVResult"].Value<JArray>();
  25. appMenu = appMenuarray.ToObject<List<ImportListByVesselVoyageGetILBV>>();
  26. ViewBag.ILBV = appMenu;
  27. }
  28.  
  29. return View();
  30. }
  31. catch (Exception ex)
  32. {
  33.  
  34. return PartialView("ImportListByVesselVoyage", appMenu);
  35. }
  36. finally
  37. {
  38. client.Dispose();
  39. client = null;
  40. }
  41. }
  42.  
  43. @using (Html.BeginForm("ImportListByVesselVoyage", "Containerized", FormMethod.Post))
  44. {
  45. <div class="box-body">
  46. <div class="form-group">
  47. <div class="col-sm-6">
  48. @Html.TextBoxFor(model => model.reg)
  49. </div>
  50. </div>
  51. </div>
  52. <div class="box-footer">
  53. <button type="submit" class="btn btn-info pull-right"><i class="fa fa-search"></i>Search</button>
  54. </div>
  55. <div id="result">
  56. <div class="col-md-12">
  57. <div class="box">
  58. <div class="box-body no-padding">
  59. <table class="table table-striped">
  60. <tbody>
  61. <tr>
  62. <th>Container No.</th>
  63. <th>Operator</th>
  64. <th>Status</th>
  65. <th>Size</th>
  66. <th>Commodity</th>
  67. <th>Destination</th>
  68. <th>Location</th>
  69. <th>Discharged</th>
  70. <th>Delivered</th>
  71. </tr>
  72. @foreach (var item in ViewBag.ILBV)
  73. {
  74. <tr>
  75. <td>@item.ContainerNo</td>
  76. <td>@item.Operator</td>
  77. <td>@item.Status</td>
  78. <td>@item.Size</td>
  79. <td>@item.Commodity</td>
  80. <td>@item.Destination</td>
  81. <td>@item.Location</td>
  82. <td>@item.Discharged</td>
  83. <td>@item.Delivered</td>
  84. </tr>
  85. }
  86. </tbody>
  87. </table>
  88. </div>
  89. <div class="box-footer clearfix">
  90. <ul class="pagination pagination-sm no-margin pull-right"></ul>
  91. </div>
  92. </div>
  93. </div>
Add Comment
Please, Sign In to add comment