Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Post(CpjsProcessFormViewModel viewModel)
- {
- if (ModelState.IsValid)
- {
- try
- {
- if (!string.IsNullOrEmpty(viewModel.UserName) && !string.IsNullOrEmpty(viewModel.Password))
- {
- _sysproCredentials.UserName = viewModel.UserName;
- _sysproCredentials.Password = viewModel.Password;
- }
- var serviceController = new ServiceController(_unitOfWork,
- new ControlPlanJobProcessor(_sysproService, _sysproCredentials));
- serviceController.ProcessControlPlan(viewModel.ControlPlanId, viewModel.CloseJob, true,
- User.Identity.GetUserId());
- }
- catch (Exception e)
- {
- ModelState.AddModelError("", e.Message);
- return View(viewModel);
- }
- return RedirectToAction("Post", new { id = viewModel.ControlPlanId, message = "Successfully posted to Syspro" });
- }
- return View(viewModel);
- }
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
- @Html.HiddenFor(model => model.ControlPlanId)
- <div class="form-horizontal">
- @Html.ValidationSummary(false, "", new { @class = "text-danger" })
- }
Add Comment
Please, Sign In to add comment