public ActionResult Approve(int id, String from)
        {
            if (getCurrentUser() == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                Documents       documents        = idocuments.GetDocument(1);
                OverTimeRequest overTimeRequest  = ioverTimeRequest.GetOverTimeRequest(id);
                WorkflowDetail  workflow         = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id);
                int             nextStatus       = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status);
                int             rolePriority     = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, getCurrentUser().u_role_id);
                int             nextStatusbyUser = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, rolePriority);
                int             MinofWorkflow    = iworkflowDetail.getMinOfWorkFlow(overTimeRequest.rq_workflow_id);
                if (nextStatus == nextStatusbyUser)
                {
                    if (overTimeRequest.rq_hold_yn == "Y")
                    {
                        TempData["errorMessage"] = ("This Document is Hold by Someone,Click Hold Details For more Information");
                        return(RedirectToAction(nameof(Approval)));
                    }
                    else
                    {
                        WorkflowDetail  workflowDetail  = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus);
                        WorkflowTracker workflowTracker = new WorkflowTracker();
                        workflowTracker.wt_doc_id             = documents.dc_id;
                        workflowTracker.wt_fun_doc_id         = overTimeRequest.rq_id;
                        workflowTracker.wt_status             = overTimeRequest.rq_status;
                        workflowTracker.wt_workflow_id        = overTimeRequest.rq_workflow_id;
                        workflowTracker.wt_role_id            = getCurrentUser().u_role_id;
                        workflowTracker.wt_role_description   = getCurrentUser().u_role_description;
                        workflowTracker.wt_status_to          = nextStatus;
                        workflowTracker.wt_assign_role        = workflowDetail.wd_role_id;
                        workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description;
                        workflowTracker.wt_approve_status     = "Approved";
                        workflowTracker.wt_cre_by             = getCurrentUser().u_id;
                        workflowTracker.wt_cre_by_name        = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name;
                        workflowTracker.wt_cre_date           = DateTime.Now;
                        iworkflowTracker.Add(workflowTracker);
                        overTimeRequest.rq_status = nextStatus;
                        ioverTimeRequest.Update(overTimeRequest);

                        return(RedirectToAction(from));
                    }
                }
                else
                {
                    return(RedirectToAction(from));
                }
            }
        }
Example #2
0
        public string Approve(int id, String reason, int u_id)
        {
            // reason = "";
            Result result = new Result();

            try
            {
                User user = iuser.GetUser(u_id);
                Role role = irole.GetRole(user.u_role_id);

                Documents       documents        = idocuments.GetDocument(1);
                OverTimeRequest overTimeRequest  = ioverTimeRequest.GetOverTimeRequest(id);
                WorkflowDetail  workflow         = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id);
                int             nextStatus       = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status);
                int             rolePriority     = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, role.r_id);
                int             nextStatusbyUser = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, rolePriority);
                int             MinofWorkflow    = iworkflowDetail.getMinOfWorkFlow(overTimeRequest.rq_workflow_id);
                if (nextStatus == nextStatusbyUser)
                {
                    if (overTimeRequest.rq_hold_yn == "Y")
                    {
                        result.Objects = null;
                        result.Message = "You have No privilage to unHold";
                        return(JsonConvert.SerializeObject(result));
                    }
                    else
                    {
                        WorkflowDetail  workflowDetail  = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus);
                        WorkflowTracker workflowTracker = new WorkflowTracker();
                        workflowTracker.wt_doc_id             = documents.dc_id;
                        workflowTracker.wt_fun_doc_id         = overTimeRequest.rq_id;
                        workflowTracker.wt_status             = overTimeRequest.rq_status;
                        workflowTracker.wt_workflow_id        = overTimeRequest.rq_workflow_id;
                        workflowTracker.wt_role_id            = user.u_role_id;
                        workflowTracker.wt_role_description   = role.r_description;
                        workflowTracker.wt_status_to          = nextStatus;
                        workflowTracker.wt_assign_role        = workflowDetail.wd_role_id;
                        workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description;
                        workflowTracker.wt_approve_status     = "Approved";
                        workflowTracker.wt_cre_by             = user.u_id;
                        workflowTracker.wt_cre_by_name        = user.u_name + "-" + user.u_full_name;
                        workflowTracker.wt_cre_date           = DateTime.Now;
                        iworkflowTracker.Add(workflowTracker);
                        overTimeRequest.rq_status = nextStatus;
                        ioverTimeRequest.Update(overTimeRequest);

                        result.Objects = null;
                        result.Message = "Success";
                        return(JsonConvert.SerializeObject(result));
                    }
                }
                else
                {
                    result.Objects = null;
                    result.Message = "You have No privilage to Approve";
                    return(JsonConvert.SerializeObject(result));
                }
            }
            catch (Exception ex)
            {
                var st = new StackTrace(ex, true);
                // Get the top stack frame
                var frame = st.GetFrame(0);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                result.Objects = null;
                result.Message = ex.Message + "" + line;

                return(JsonConvert.SerializeObject(result));
            }
        }