Esempio n. 1
0
        public Result Add(DelegationsDetailsBLL DelegationDetailBLL)
        {
            Result result = new Result();

            // validate employee already exists
            DelegationsDetails employee = new DelegationsDetailsDAL().GetDelegationsDetailsByDelegationID(DelegationDetailBLL.Delegation.DelegationID)
                                          .Where(d => d.EmployeeCareerHistoryID == DelegationDetailBLL.EmployeeCareerHistory.EmployeeCareerHistoryID).FirstOrDefault();

            if (employee != null)
            {
                result.Entity     = null;
                result.EnumType   = typeof(DelegationsValidationEnum);
                result.EnumMember = DelegationsValidationEnum.RejectedBecauseAlreadyExist.ToString();

                return(result);
            }

            // other validation
            result = new EmployeeDelegationBLL(DelegationDetailBLL.Delegation.DelegationStartDate, DelegationDetailBLL.Delegation.DelegationEndDate, DelegationDetailBLL.Delegation.DelegationKind.DelegationKindID, new EmployeesCodesBLL()
            {
                EmployeeCodeID = DelegationDetailBLL.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
            }).IsValid();

            if (result.EnumMember == DelegationsValidationEnum.Done.ToString())
            {
                result = new Result();
                DelegationsDetails DelegationDetail = new DelegationsDetails()
                {
                    DelegationID            = DelegationDetailBLL.Delegation.DelegationID,
                    EmployeeCareerHistoryID = DelegationDetailBLL.EmployeeCareerHistory.EmployeeCareerHistoryID,
                    CreatedDate             = DateTime.Now,
                    CreatedBy = DelegationDetailBLL.LoginIdentity.EmployeeCodeID,
                    IsPassengerOrderCompensation = DelegationDetailBLL.IsPassengerOrderCompensation
                };
                this.DelegationDetailID = new DelegationsDetailsDAL().Insert(DelegationDetail);
                if (this.DelegationDetailID != 0)
                {
                    result.Entity     = null;
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.Done.ToString();
                }
            }
            return(result);
        }
Esempio n. 2
0
        public virtual Result Add()
        {
            Result result = null;

            // validate employees
            if (DALInstance.DelegationsDetails == null || DALInstance.DelegationsDetails.Count <= 0)
            {
                result            = new Result();
                result.Entity     = null;
                result.EnumType   = typeof(DelegationsValidationEnum);
                result.EnumMember = DelegationsValidationEnum.RejectedBecauseEmployeeRequired.ToString();

                return(result);
            }

            // validate employees delegation limit
            foreach (DelegationsDetailsBLL dd in this.DelegationsDetails)
            {
                result = new EmployeeDelegationBLL(this.DelegationStartDate, this.DelegationEndDate, this.DelegationKind.DelegationKindID, new EmployeesCodesBLL()
                {
                    EmployeeCodeID = dd.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                }).IsValid();

                if (result.EnumMember != DelegationsValidationEnum.Done.ToString())
                {
                    return(result);
                }
            }
            // setting result is null in case of "DONE"
            if (result.EnumMember == DelegationsValidationEnum.Done.ToString())
            {
                result = null;
            }

            return(result);
        }