Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. public class APIDataViewModel
  2. {
  3. public ChangeBuildState ChangeBuildStateValue { get; set; }
  4. public int SelectedIntValue { get; set; }
  5. }
  6.  
  7. public class ChangeBuildState
  8. {
  9. public Dictionary<int, string> BuildState { get; set; }
  10.  
  11. public ChangeBuildState()
  12. {
  13. BuildState = new Dictionary<int, string>()
  14. {
  15. { -1, "Halt"},
  16. { 4, "Ready"}
  17. };
  18.  
  19. }
  20. }
  21.  
  22. @using (Ajax.BeginForm(
  23. "ChangeBuildStateRun",
  24. "Stores",
  25. new
  26. {
  27. Area = "",
  28. locationNumber = Model.locationNumber,
  29. macAddress = Model.mac,
  30. buildState = Model.SelectedIntValue
  31. },
  32. new AjaxOptions
  33. {
  34. UpdateTargetId = "APIModal",
  35. InsertionMode = InsertionMode.Replace,
  36. HttpMethod = "POST",
  37. OnSuccess = "CloseAddWkstnModals",
  38. OnFailure = "APIFailed"
  39. },
  40. new
  41. {
  42. id = "ChangeBuildStateForm"
  43. }))
  44.  
  45. {
  46. <div class="row Padding_Std center-block">
  47. <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
  48. <label class="ModalInputLblStyle">IP Address: </label>
  49. @Html.EditorFor(m => m.ipaddress,
  50. new
  51. {
  52. htmlAttributes = new
  53. {
  54. @class = "input-sm AddEditWorkstationTBoxStyle",
  55. @readonly = "readonly",
  56. @disabled = "disabled"
  57. }
  58. })
  59. </div>
  60. </div>
  61. <div class="row Padding_Std center-block">
  62. <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
  63. <label class="ModalInputLblStyle">MAC Address: </label>
  64. @Html.EditorFor(m => m.mac,
  65. new
  66. {
  67. htmlAttributes = new
  68. {
  69. @class = "input-sm AddEditWorkstationTBoxStyle",
  70. @readonly = "readonly",
  71. @disabled = "disabled"
  72. }
  73. })
  74. </div>
  75. </div>
  76. <div class="row Padding_Std center-block">
  77. <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
  78. <label class="storeSearchInputLblStyle">Select Build State: </label>
  79. @Html.DropDownListFor(m => m.SelectedIntValue,
  80. new SelectList(
  81. Model.ChangeBuildStateValue.BuildState,
  82. "Key",
  83. "Value"),
  84. "--- Select ---",
  85. new { @class = "DDL_LogLevelStyle" })
  86. </div>
  87. </div>
  88. <div class="row">
  89. <div class="col-sm-9 col-sm-offset-4">
  90. <div class="col-md-4 col-sm-3 center-block" id="BtnChangeBuildState">
  91. <input type="submit" value="Change Build State" class="btn btn-sm button-alt-1 button-v center-block" />
  92. </div>
  93. ...
  94. </div>
  95. }
  96.  
  97. public ActionResult ChangeBuildStateRun(int locationNumber = 0, string macAddress = "", int buildState = 999)
  98. {
  99. APIDataViewModel model = new APIDataViewModel();
  100. model.locationNumber = locationNumber.ToString();
  101. model.mac = macAddress;
  102. try
  103. {
  104. bool apiCallResult = _epmService.UpdateStoreWorkstationBuildState(locationNumber, macAddress, buildState);
  105. model.webapi_name = "Change Build State";
  106. model.response_type = "ChangeBuild";
  107. model.success = apiCallResult;
  108. return PartialView("_APIResults", model);
  109. }
  110. catch
  111. {
  112. model.webapi_name = "Change Build State";
  113. model.response_type = "ChangeBuild";
  114. model.success = false;
  115. return PartialView("_APIResults", model);
  116. }
  117. }
Add Comment
Please, Sign In to add comment