Beispiel #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);
        }
Beispiel #2
0
 internal DelegationsDetailsBLL MapDelegationDetail(DelegationsDetails DelegationDetail)
 {
     try
     {
         DelegationsDetailsBLL DelegationDetailBLL = null;
         if (DelegationDetail != null)
         {
             DelegationDetailBLL = new DelegationsDetailsBLL()
             {
                 DelegationDetailID           = DelegationDetail.DelegationDetailID,
                 Delegation                   = new BaseDelegationsBLL().MapDelegation(DelegationDetail.Delegations),
                 EmployeeCareerHistory        = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(DelegationDetail.EmployeesCareersHistory),
                 IsPassengerOrderCompensation = DelegationDetail.IsPassengerOrderCompensation
             };
         }
         return(DelegationDetailBLL);
     }
     catch
     {
         throw;
     }
 }