Example #1
0
        public ActionResult GetApprovers(string WorkflowID, int RequestStageID)
        {
            string errorResult = "{{\"employee_number\":\"{0}\",\"name\":\"{1}\"}}";

            if (string.IsNullOrEmpty(WorkflowID))
            {
                errorResult = string.Format(errorResult, "Error", "Invalid entry detected");
                return(Content(errorResult, "application/json"));
            }

            var profile = (RequestStageID == 20) ? LINQCalls.getHRApproverNames(WorkflowID, RequestStageID):LINQCalls.getApproverNumbersToNames(WorkflowID, RequestStageID);

            if (profile == null || profile.Count() <= 0)
            {
                errorResult = string.Format(errorResult, null, "No approvers found for the entry");
                return(Content(errorResult, "application/json"));
            }
            else
            {
                return(Json(profile, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public ActionResult PassportInputForm(SuperPassportModel superPassportModel, string PassportAction)
        {
            List <RequestDetails> requestDetails = superPassportModel.RequestDetails;

            IEnumerable <RequestDetails> requestdetails = superPassportModel.RequestDetails;
            string retVal = "";

            switch (PassportAction)
            {
            case "CountryCountRefresh":

                //Form is submitted when the user selects the number of countries
                List <PassportDetails> passportDetails = new List <PassportDetails>();
                string sex = (superPassportModel.StaffADProfile.gender.Equals(1)) ? SEX_FEMALE: SEX_MALE;

                for (int i = 0; i < superPassportModel.StaffADProfile.countryCount; i++)
                {
                    PassportDetails pDetails = new PassportDetails();
                    pDetails.entry_key            = "";
                    pDetails.passportAuthority    = "";
                    pDetails.passportDateOfExpiry = "";
                    pDetails.passportDateOfIssue  = "";
                    pDetails.passportNationality  = "";
                    pDetails.passportNumber       = "";
                    pDetails.passportOtherNames   = "";
                    pDetails.passportPlaceOfBirth = "";
                    pDetails.passportSex          = sex;
                    pDetails.passportSurname      = "";
                    pDetails.passportType         = "P";
                    pDetails.passportDateOfBirth  = superPassportModel.StaffADProfile.dob;
                    pDetails.Nationality          = SelectListItemHelper.GetCountries();
                    passportDetails.Add(pDetails);
                }

                superPassportModel.PassportDetails = passportDetails;
                break;

            case "Deny":
                // Good. let's send this f@*ker back
                //requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superPassportModel.StaffADProfile.appperiod + "_" + superPassportModel.StaffADProfile.branch_code; return c; }).ToList();
                requestDetails.Select(c => { c.workflowid = superPassportModel.WorkflowID; return(c); }).ToList();

                // SAVE the value to the DATABASE
                requestdetails = superPassportModel.RequestDetails;
                //dataTable = DataHandlers.ToDataTable(requestdetails);

                //retVal = new AppDatabase().inputPassportEntries(dataTable, superPassportModel, "AppraisalDbConnectionString", DENIED_STATUS);

                if (retVal != null)
                {
                    TempData["UploadComplete"]     = "false";
                    TempData["ErrorMessage"]       = retVal;
                    TempData["superPassportModel"] = superPassportModel;
                }
                else
                {
                    //String.format(SUMBMITTEDMSG)--add the approvers
                    var approvers = LINQCalls.getApproverNames(superPassportModel.WorkflowID, -1);
                    TempData["PostBackMessage"] = DENIEDMSG;
                    TempData["Approvers"]       = string.Join("\\n", approvers.ToArray());
                    return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
                }
                break;

            case "Submit":
                if (ModelState.IsValid)
                {
                    if (!checkVlaidFileTypes(superPassportModel.PassportDetails))
                    {
                        ViewBag.ErrorMessage = "Invalid file type. Only \"pdf\" files are supported.";
                        //TempData["superPassportModel"] = superPassportModel;
                    }
                    else
                    {
                        IEnumerable <PassportDetails> _passportDetails = superPassportModel.PassportDetails;
                        _passportDetails.Select(c => { c.entry_key = superPassportModel.StaffADProfile.employee_number + "_" + c.passportNumber.ToUpper(); return(c); }).ToList();
                        _passportDetails.Select(c => { c.passportFileName = c.passportUpload.FileName; return(c); }).ToList();

                        _passportDetails.Select(c => { c.passportNumber = c.passportNumber.ToUpper();       return(c); }).ToList();
                        _passportDetails.Select(c => { c.passportSurname = c.passportSurname.ToUpper();      return(c); }).ToList();
                        _passportDetails.Select(c => { c.passportOtherNames = c.passportOtherNames.ToUpper();   return(c); }).ToList();
                        _passportDetails.Select(c => { c.passportPlaceOfBirth = c.passportPlaceOfBirth.ToUpper(); return(c); }).ToList();
                        _passportDetails.Select(c => { c.passportAuthority = c.passportAuthority.ToUpper();    return(c); }).ToList();

                        _passportDetails.Select(c => { c.passportContentType = c.passportUpload.ContentType; return(c); }).ToList();
                        _passportDetails.Select(c => {
                            Stream fs           = c.passportUpload.InputStream;
                            BinaryReader br     = new BinaryReader(fs);
                            byte[] bytes        = br.ReadBytes((Int32)fs.Length);
                            c.passportFileBytes = bytes;
                            return(c);
                        }).ToList();

                        DataTable dataTable = new DataTable();
                        dataTable = DataHandlers.ToDataTable(_passportDetails);

                        string _retVal = new AppDatabase().inputPassportEntries(dataTable, superPassportModel, "AppraisalDbConnectionString", SUBMIT_STATUS);

                        if (_retVal != null)
                        {
                            TempData["UploadComplete"]     = "false";
                            TempData["ErrorMessage"]       = _retVal;
                            TempData["superPassportModel"] = superPassportModel;
                        }
                        else
                        {
                            int newstageid = 0;
                            switch (superPassportModel.RequestStageID)
                            {
                            case 0:
                                newstageid = 3;
                                break;

                            case -1:
                                newstageid = 3;
                                break;

                            case 3:
                                newstageid = 20;
                                break;

                            case 20:
                                newstageid = 100;
                                break;
                            }

                            var approvers = LINQCalls.getHRApproverNames(superPassportModel.WorkflowID, newstageid);
                            TempData["PostBackMessage"] = SUMBMITTEDMSG;
                            TempData["Approvers"]       = string.Join("\\n", approvers.ToArray());
                            return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
                        }
                    }
                }
                break;
            }

            //superPassportModel.RequestDetails = requestDetails;
            TempData["superPassportModel"] = superPassportModel;
            return(RedirectToAction("PassportInputForm"));
        }