public ActionResult Reroute(string RerouteAction, RerouteModel rerouteModel) { //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = Session["UserName"] as string; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(View()); } // staffADProfile = new LINQCalls().setInitiatorFields( staffADProfile ); /* * if( staffADProfile.branch_code==null ){ * ViewBag.ErrorMessage="Your profile is not properly setup for Target. Please contact Human Resources."; * return View(); * } */ staffADProfile.appperiod = "20150712"; string _retVal = new AppDatabase().routeTargetEntries(rerouteModel, staffADProfile, "AppraisalDbConnectionString"); Debug.WriteLine(_retVal); if (_retVal != null) { TempData["UploadComplete"] = "false"; ViewBag.ErrorMessage = _retVal; TempData["rerouteModel"] = rerouteModel; } else { int newstageid = Int32.Parse(rerouteModel.NewRequestStageCode); var approvers = new LINQCalls().getApproverNames(rerouteModel.WorkflowID, newstageid); TempData["PostBackMessage"] = REROUTEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("Reports", "Reports", new { UserName = Session["UserName"] as string, ReportMode = Session["ReportMode"] as string })); } return(RedirectToAction("Reroute", "Reroute", new { UserName = Session["UserName"] as string, ReportMode = Session["ReportMode"] as string })); }
public ActionResult TargetInputForm(SuperInputTargetModel superInputTargetModel, string TargetAction, string StaffNumber) { List <RequestDetails> requestDetails = superInputTargetModel.RequestDetails; IEnumerable <RequestDetails> requestdetails = superInputTargetModel.RequestDetails; DataTable dataTable = DataHandlers.ToDataTable(requestdetails); string retVal = ""; switch (TargetAction) { case "AddStaff": //ADD the new Staff from the list if (AddStaff(superInputTargetModel)) { requestDetails.Add(TempData["newStaff"] as RequestDetails); } break; case "DeleteStaff": //DELETE the selected Staff from the list if (DeleteStaff(superInputTargetModel, StaffNumber)) { requestDetails = TempData["requestDetails"] as List <RequestDetails>; } break; case "Reset": // RESET all entries to ZERO requestDetails.Select(c => { c.cabal = c.cabal_l = c.sabal = c.sabal_l = c.fd = c.fx = c.inc = c.inc_l = c.rv = "0"; return(c); }).ToList(); break; case "Save": // GOSH!!! I CAN'T HIDE THE entry_key & workflow_id COLUMN---REBUILD IT AGAIN requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE requestdetails = superInputTargetModel.RequestDetails; dataTable = DataHandlers.ToDataTable(requestdetails); retVal = new AppDatabase().inputTargetEntries(dataTable, superInputTargetModel, "AppraisalDbConnectionString", SAVED_STATUS); Debug.WriteLine(retVal); if (retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { return(RedirectToAction("MyEntries", "MyEntries", new { UserName = Session["UserName"] })); } break; case "Deny": // Good. let's send this f@*ker back requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE requestdetails = superInputTargetModel.RequestDetails; dataTable = DataHandlers.ToDataTable(requestdetails); retVal = new AppDatabase().inputTargetEntries(dataTable, superInputTargetModel, "AppraisalDbConnectionString", DENIED_STATUS); Debug.WriteLine(retVal); if (retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { //String.format(SUMBMITTEDMSG)--add the approvers var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID, -1); TempData["PostBackMessage"] = DENIEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } break; case "Submit": //LET'S SUBMIT THIS SHIT requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE IEnumerable <RequestDetails> _requestdetails = superInputTargetModel.RequestDetails; if (superInputTargetModel.EntryModel != null) { //EDITTED REQUEST---APPROVAL OR RESUBMISSION requestDetails.Select(c => { c.requeststageid = superInputTargetModel.RequestStageID; c.requeststage = superInputTargetModel.RequestStage; return(c); }).ToList(); } DataTable _dataTable = DataHandlers.ToDataTable(_requestdetails); StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.branch_code = new LINQCalls().getEntryProfile(superInputTargetModel.WorkflowID).branch_code; staffADProfile.branch_name = new LINQCalls().getEntryProfile(superInputTargetModel.WorkflowID).branch_name; string _retVal = new AppDatabase().inputTargetEntries(_dataTable, superInputTargetModel, "AppraisalDbConnectionString", SUBMIT_STATUS); Debug.WriteLine(_retVal); if (_retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = _retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { //String.format(SUMBMITTEDMSG)--add the approvers int newstageid = 0; switch (superInputTargetModel.RequestStageID) { case 0: newstageid = 3; break; case -1: newstageid = 3; break; case 3: newstageid = 20; break; case 20: newstageid = 100; break; } /*EntryModel EntryModel = new LINQCalls().getWorkflowEntry( superInputTargetModel.WorkflowID ); * var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID,EntryModel.RequestStageId);*/ var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID, newstageid); TempData["PostBackMessage"] = SUMBMITTEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } break; } superInputTargetModel.RequestDetails = requestDetails; TempData["superInputTargetModel"] = superInputTargetModel; return(RedirectToAction("TargetInputForm", new { UserName = Session["UserName"] as string })); }