Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class APIDataViewModel
- {
- public ChangeBuildState ChangeBuildStateValue { get; set; }
- public int SelectedIntValue { get; set; }
- }
- public class ChangeBuildState
- {
- public Dictionary<int, string> BuildState { get; set; }
- public ChangeBuildState()
- {
- BuildState = new Dictionary<int, string>()
- {
- { -1, "Halt"},
- { 4, "Ready"}
- };
- }
- }
- @using (Ajax.BeginForm(
- "ChangeBuildStateRun",
- "Stores",
- new
- {
- Area = "",
- locationNumber = Model.locationNumber,
- macAddress = Model.mac,
- buildState = Model.SelectedIntValue
- },
- new AjaxOptions
- {
- UpdateTargetId = "APIModal",
- InsertionMode = InsertionMode.Replace,
- HttpMethod = "POST",
- OnSuccess = "CloseAddWkstnModals",
- OnFailure = "APIFailed"
- },
- new
- {
- id = "ChangeBuildStateForm"
- }))
- {
- <div class="row Padding_Std center-block">
- <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
- <label class="ModalInputLblStyle">IP Address: </label>
- @Html.EditorFor(m => m.ipaddress,
- new
- {
- htmlAttributes = new
- {
- @class = "input-sm AddEditWorkstationTBoxStyle",
- @readonly = "readonly",
- @disabled = "disabled"
- }
- })
- </div>
- </div>
- <div class="row Padding_Std center-block">
- <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
- <label class="ModalInputLblStyle">MAC Address: </label>
- @Html.EditorFor(m => m.mac,
- new
- {
- htmlAttributes = new
- {
- @class = "input-sm AddEditWorkstationTBoxStyle",
- @readonly = "readonly",
- @disabled = "disabled"
- }
- })
- </div>
- </div>
- <div class="row Padding_Std center-block">
- <div class="col-sm-7 col-sm-offset-4 col-md-7 col-md-offset-2 Padding_Std">
- <label class="storeSearchInputLblStyle">Select Build State: </label>
- @Html.DropDownListFor(m => m.SelectedIntValue,
- new SelectList(
- Model.ChangeBuildStateValue.BuildState,
- "Key",
- "Value"),
- "--- Select ---",
- new { @class = "DDL_LogLevelStyle" })
- </div>
- </div>
- <div class="row">
- <div class="col-sm-9 col-sm-offset-4">
- <div class="col-md-4 col-sm-3 center-block" id="BtnChangeBuildState">
- <input type="submit" value="Change Build State" class="btn btn-sm button-alt-1 button-v center-block" />
- </div>
- ...
- </div>
- }
- public ActionResult ChangeBuildStateRun(int locationNumber = 0, string macAddress = "", int buildState = 999)
- {
- APIDataViewModel model = new APIDataViewModel();
- model.locationNumber = locationNumber.ToString();
- model.mac = macAddress;
- try
- {
- bool apiCallResult = _epmService.UpdateStoreWorkstationBuildState(locationNumber, macAddress, buildState);
- model.webapi_name = "Change Build State";
- model.response_type = "ChangeBuild";
- model.success = apiCallResult;
- return PartialView("_APIResults", model);
- }
- catch
- {
- model.webapi_name = "Change Build State";
- model.response_type = "ChangeBuild";
- model.success = false;
- return PartialView("_APIResults", model);
- }
- }
Add Comment
Please, Sign In to add comment