Example #1
0
        /// <summary>
        /// Validate update date for JR item
        /// </summary>
        /// <param name="objUI"></param>
        /// <param name="objDb"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool IsValidUpdateDate(JobRequestItem objUI, JobRequestItem objDb, out Message msg)
        {
            bool isValid = false;
            msg = null;

            try
            {
                if ((objUI != null) && (objUI.UpdateDate != null) && (objDb != null))
                {
                    if (objDb.UpdateDate.ToString().Equals(objUI.UpdateDate.ToString()))
                    {
                        isValid = true;
                    }
                    else
                    {
                        msg = new Message(MessageConstants.E0025, MessageType.Error, "Job Request Id " + objDb.ID);
                    }
                }
            }
            catch
            {
                throw;
            }

            return isValid;
        }
Example #2
0
        public Message HRFillData(JobRequestItem objUI)
        {
            Message msg = null;
            try
            {
                JobRequestItem objDb = GetItemById(objUI.ID);

                if (objDb != null)
                {
                    // Check valid update date
                    if (IsValidUpdateDate(objUI, objDb, out msg))
                    {
                        //new JobRequestLogDao().WriteUpdateLogForRoleHR(objUI, ELogAction.Update);
                        // Update info by objUI
                        objDb.Candidate = objUI.Candidate;
                        objDb.Approval = objUI.Approval;
                        objDb.EmpID = objUI.EmpID;
                        objDb.FinalTitleId = objUI.FinalTitleId;
                        objDb.IssueDate = objUI.IssueDate;
                        objDb.Gender = objUI.Gender;
                        objDb.ActualStartDate = objUI.ActualStartDate;
                        objDb.ProbationMonths = objUI.ProbationMonths;
                        objDb.ProbationSalary = !string.IsNullOrEmpty(objUI.ProbationSalary) ? EncryptUtil.Encrypt(objUI.ProbationSalary) : null;
                        objDb.ContractedSalary = !string.IsNullOrEmpty(objUI.ContractedSalary) ? EncryptUtil.Encrypt(objUI.ContractedSalary) : null;
                        objDb.ProbationSalaryNote = objUI.ProbationSalaryNote;
                        objDb.ContractedSalaryNote = objUI.ContractedSalaryNote;
                        objDb.StatusID = objUI.StatusID;
                        objDb.Title = objUI.Title;

                        objDb.UpdateDate = DateTime.Now;
                        objDb.UpdatedBy = objUI.UpdatedBy;

                        // close Job request if all its items don't have Open status
                        int count = objDb.JobRequest.JobRequestItems.Where(i => i.StatusID == Constants.JR_ITEM_STATUS_OPEN && i.DeleteFlag == false).Count();
                        if (count == 0)
                        {
                            int completeCount = objDb.JobRequest.JobRequestItems.Where(p => p.StatusID == Constants.JR_ITEM_STATUS_SUCCESS).Count();
                            if (completeCount > 0)
                                objDb.JobRequest.WFResolutionID = Constants.RESOLUTION_COMPLETED_ID;
                            else
                                objDb.JobRequest.WFResolutionID = Constants.RESOLUTION_CANCEL_ID;
                            objDb.JobRequest.WFStatusID = Constants.STATUS_CLOSE;
                        }

                        // Submit changes to dbContext
                        dbContext.SubmitChanges();

                        // Show success message
                        msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Request Item'" + Constants.JOB_REQUEST_ITEM_PREFIX + objUI.ID + "'", "updated");
                    }
                }
            }
            catch
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }