示例#1
0
        internal EmployeesEvaluationsBLL MapEmployeeEvaluation(EmployeesEvaluations EmployeeEvaluation)
        {
            try
            {
                EmployeesEvaluationsBLL EmployeeEvaluationBLL = null;
                if (EmployeeEvaluation != null)
                {
                    EmployeeEvaluationBLL = new EmployeesEvaluationsBLL()
                    {
                        EmployeeEvaluationID  = EmployeeEvaluation.EmployeeEvaluationID,
                        MaturityYearsBalances = new MaturityYearsBalancesBLL().MapMaturityYearBalance(EmployeeEvaluation.MaturityYearsBalances),
                        EvaluationPoints      = new EvaluationPointsBLL().MapEvaluationPoint(EmployeeEvaluation.EvaluationPoints),
                        EvaluationDegree      = (float)EmployeeEvaluation.EvaluationDegree,
                        EvaluationPointsEnum  = (EvaluationPointsEnum)EmployeeEvaluation.EvaluationPointID,
                        EmployeeCode          = new EmployeesCodesBLL().MapEmployeeCode(EmployeeEvaluation.EmployeesCodes),
                        CreatedBy             = new EmployeesCodesBLL().MapEmployeeCode(EmployeeEvaluation.CreatedByNav),
                        CreatedDate           = EmployeeEvaluation.CreatedDate.Value
                    };
                    EmployeeEvaluationBLL.EmployeeEvaluationDetails = new List <EmployeesEvaluationsDetailsBLL>();

                    foreach (var item in EmployeeEvaluation.EmployeesEvaluationsDetails)
                    {
                        EmployeeEvaluationBLL.EmployeeEvaluationDetails.Add(new EmployeesEvaluationsDetailsBLL().MapEmployeeEvaluationDetails(item));
                    }
                }
                return(EmployeeEvaluationBLL);
            }
            catch
            {
                throw;
            }
        }
        public virtual Result Add()
        {
            try
            {
                Result result = null;
                if (this.DirectManagerEvaluation > 50)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EmployeesEvaluationsValidationEnum);
                    result.EnumMember = EmployeesEvaluationsValidationEnum.RejectedBecauseOfDirectManagerEvaluationIsNotBetweenZeroAndFifty.ToString();
                    return(result);
                }
                if (this.TimeAttendanceEvaluation > 35)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EmployeesEvaluationsValidationEnum);
                    result.EnumMember = EmployeesEvaluationsValidationEnum.RejectedBecauseOfTimeAttendanceEvaluationIsNotBetweenZeroAndThirtyFive.ToString();
                    return(result);
                }
                if (this.ViolationsEvaluation > 15)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EmployeesEvaluationsValidationEnum);
                    result.EnumMember = EmployeesEvaluationsValidationEnum.RejectedBecauseOfViolationsEvaluationIsNotBetweenZeroAndFifteen.ToString();
                    return(result);
                }

                EmployeesEvaluationsBLL EmployeesEvaluationBLL = new EmployeesEvaluationsBLL().GetByEmployeeEvaluationID(this.EmployeeEvaluation.EmployeeEvaluationID);
                List <EmployeesEvaluationsDetailsBLL> EmployeesEvaluationBLLList = new EmployeesEvaluationsBLL().GetByEmployeeEvaluationID(this.EmployeeEvaluation.EmployeeEvaluationID).EmployeeEvaluationDetails;
                if (EmployeesEvaluationBLLList.Exists(x => x.EvaluationQuarter.EvaluationQuarterID.Equals(this.EvaluationQuarter.EvaluationQuarterID)) && EmployeesEvaluationBLL.MaturityYearsBalances.MaturityYearID.Equals(this.EmployeeEvaluation.MaturityYearsBalances.MaturityYearID))
                {
                    result = new Result()
                    {
                        Entity     = this,
                        EnumType   = typeof(EmployeesEvaluationsValidationEnum),
                        EnumMember = EmployeesEvaluationsValidationEnum.RejectedBecauseOfEvaluationQuarterAlreadyExistsInCurrentYear.ToString(),
                    };
                    return(result);
                }

                EmployeesEvaluationsDetails EmployeeEvaluationDetail = new EmployeesEvaluationsDetails()
                {
                    EmployeeEvaluationID     = this.EmployeeEvaluation.EmployeeEvaluationID,
                    DirectManagerEvaluation  = this.DirectManagerEvaluation,
                    TimeAttendanceEvaluation = this.TimeAttendanceEvaluation,
                    ViolationsEvaluation     = this.ViolationsEvaluation,
                    EvaluationQuarterID      = this.EvaluationQuarter.EvaluationQuarterID,
                    CreatedBy   = this.LoginIdentity.EmployeeCodeID,
                    CreatedDate = DateTime.Now,
                };
                int RecordID = new EmployeesEvaluationsDetailsDAL().Insert(EmployeeEvaluationDetail);
                result = new Result()
                {
                    Entity     = this,
                    EnumType   = typeof(EmployeesEvaluationsValidationEnum),
                    EnumMember = EmployeesEvaluationsValidationEnum.Done.ToString(),
                };
                return(result);
            }
            catch
            {
                throw;
            }
        }