Guest User

Untitled

a guest
Mar 31st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. [HttpPost]
  2. [ValidateAntiForgeryToken]
  3. public ActionResult Post(CpjsProcessFormViewModel viewModel)
  4. {
  5. if (ModelState.IsValid)
  6. {
  7. try
  8. {
  9. if (!string.IsNullOrEmpty(viewModel.UserName) && !string.IsNullOrEmpty(viewModel.Password))
  10. {
  11. _sysproCredentials.UserName = viewModel.UserName;
  12. _sysproCredentials.Password = viewModel.Password;
  13. }
  14.  
  15. var serviceController = new ServiceController(_unitOfWork,
  16. new ControlPlanJobProcessor(_sysproService, _sysproCredentials));
  17. serviceController.ProcessControlPlan(viewModel.ControlPlanId, viewModel.CloseJob, true,
  18. User.Identity.GetUserId());
  19. }
  20. catch (Exception e)
  21. {
  22. ModelState.AddModelError("", e.Message);
  23. return View(viewModel);
  24. }
  25.  
  26. return RedirectToAction("Post", new { id = viewModel.ControlPlanId, message = "Successfully posted to Syspro" });
  27. }
  28.  
  29. return View(viewModel);
  30. }
  31.  
  32. @using (Html.BeginForm())
  33. {
  34. @Html.AntiForgeryToken()
  35. @Html.HiddenFor(model => model.ControlPlanId)
  36. <div class="form-horizontal">
  37. @Html.ValidationSummary(false, "", new { @class = "text-danger" })
  38. }
Add Comment
Please, Sign In to add comment