예제 #1
0
        public Result Remove(int AssigningID)
        {
            try
            {
                Result result = null;

                #region Validation if the assigning is finished or not
                BaseAssigningsBLL AssigningBLL = GetByAssigningID(AssigningID);
                if (AssigningBLL.IsFinished)
                {
                    result            = new Result();
                    result.Entity     = AssigningBLL;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfAlreadyFinished.ToString();
                    return(result);
                }
                #endregion

                new AssigningsDAL().Delete(AssigningID, this.LoginIdentity.EmployeeCodeID);
                return(result = new Result()
                {
                    EnumType = typeof(AssigningsValidationEnum),
                    EnumMember = AssigningsValidationEnum.Done.ToString()
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public virtual Result Update()
        {
            Result result = IsValid();       //null;

            if (result == null)
            {
                //BaseAssigningsBLL AssigningBLL = this.GetEmployeeActiveAssigning(this.EmployeeCareerHistory.EmployeeCareerHistoryID);
                //if (AssigningBLL != null && AssigningBLL.AssigningID != this.AssigningID)
                //{
                //    result = new Result();
                //    result.Entity = AssigningBLL;
                //    result.EnumType = typeof(AssigningsValidationEnum);
                //    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString();
                //    return result;
                //}

                #region Validation if the assigning is finished or not
                BaseAssigningsBLL AssigningBLL = GetByAssigningID(this.AssigningID);
                if (AssigningBLL.IsFinished)
                {
                    result            = new Result();
                    result.Entity     = AssigningBLL;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfAlreadyFinished.ToString();
                    return(result);
                }
                #endregion
            }
            return(result);
        }
예제 #3
0
        public static BaseAssigningsBLL GetByAssigningID(int AssigningID)
        {
            BaseAssigningsBLL assigningBLL = null;
            Assignings        assigning    = new AssigningsDAL().GetByAssigningID(AssigningID);

            if (assigning != null)
            {
                assigningBLL = new BaseAssigningsBLL().MapAssigning(assigning);
            }

            return(assigningBLL);
        }
예제 #4
0
        public virtual Result Add()
        {
            Result result = IsValid();       //null;

            if (result == null)
            {
                BaseAssigningsBLL AssigningBLL = this.GetEmployeeActiveAssigning(this.EmployeeCareerHistory.EmployeeCareerHistoryID);
                if (AssigningBLL != null)
                {
                    result            = new Result();
                    result.Entity     = AssigningBLL;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString();
                    return(result);
                }
            }
            return(result);
        }
예제 #5
0
        internal BaseAssigningsBLL MapAssigning(Assignings Assigning)
        {
            try
            {
                BaseAssigningsBLL AssigningBLL = null;
                if (Assigning != null)
                {
                    if (Assigning.AssigningTypID == (Int32)AssigningsTypesEnum.Internal)
                    {
                        AssigningBLL = new InternalAssigningBLL()
                        {
                            Job          = new JobsBLL().MapJob(Assigning.Jobs),
                            Organization = new OrganizationsStructuresBLL().MapOrganization(Assigning.OrganizationsStructures),
                            Manager      = new EmployeesCodesBLL().MapEmployeeCode(Assigning.ManagerCode)
                        };

                        ((InternalAssigningBLL)AssigningBLL).Organization.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(((InternalAssigningBLL)AssigningBLL).Organization.OrganizationID);
                    }
                    else if (Assigning.AssigningTypID == (Int32)AssigningsTypesEnum.External)
                    {
                        AssigningBLL = new ExternalAssigningBLL()
                        {
                            ExternalKSACity      = new KSACitiesBLL().MapKSACity(Assigning.KSACities),
                            ExternalOrganization = Assigning.ExternalOrganization,
                        };
                    }
                    AssigningBLL.AssigningID           = Assigning.AssigningID;
                    AssigningBLL.AssigningStartDate    = Assigning.AssigningStartDate;
                    AssigningBLL.AssigningEndDate      = Assigning.AssigningEndDate;
                    AssigningBLL.AssigningType         = new AssigningsTypesBLL().MapAssigningType(Assigning.AssigningsTypes);
                    AssigningBLL.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(Assigning.EmployeesCareersHistory);
                    AssigningBLL.IsFinished            = Assigning.IsFinished;
                    AssigningBLL.AssigningReason       = new AssigningsReasonsBLL().MapAssigningReason(Assigning.AssigningsReasons);
                    AssigningBLL.AssigningReasonOther  = "" + Assigning.AssigningReasonOther;
                    AssigningBLL.CreatedDate           = Assigning.CreatedDate;
                    AssigningBLL.CreatedBy             = new EmployeesCodesBLL().MapEmployeeCode(Assigning.CreatedByNav);
                }
                return(AssigningBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
 public virtual OrganizationsStructuresBLL GetCurrentManagerOfEmployee(int EmployeeCareerHistoryID)
 {
     try
     {
         BaseAssigningsBLL ActiveAssigning = new BaseAssigningsBLL().GetEmployeeActiveAssigning(EmployeeCareerHistoryID);
         if (ActiveAssigning != null)
         {
             return(((InternalAssigningBLL)ActiveAssigning).Organization);
         }
         else
         {
             string ManagerCodeNo = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(EmployeeCareerHistoryID).EmployeeCode.EmployeeCodeNo;
             List <OrganizationsStructuresBLL> AllOrganizationsForManager = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(ManagerCodeNo);
             return(AllOrganizationsForManager.FirstOrDefault().ParentOrganization);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
        //public BaseAssigningsBLL GetActiveAssigningByEmployeeCareerHistoryID(int EmployeeCareerHistoryID)
        //{
        //    BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL();
        //    Assignings assigning = new AssigningsDAL().GetActiveAssigningByEmployeeCareerHistoryID(EmployeeCareerHistoryID);
        //    if (assigning != null)
        //        assigningBLL = new BaseAssigningsBLL().MapAssigning(assigning);

        //    return assigningBLL;
        //}

        /// <summary>
        /// Task # 226 :
        /// Finish last assigning, based on passing parameters
        /// this function called by different modules like Promotion, Delegation, or StopWork etc
        /// Task # 310 : change CareerHistoryID to EmployeeCodeID because of task 310
        /// Task 318: Service to Cancel EServicesProxies By System
        /// </summary>
        /// <param name="EmployeeCodeID"></param>
        /// <param name="AssigningEndDate"></param>
        /// <param name="EndAssigningReason"></param>
        /// <returns></returns>
        public Result BreakLastAssigning(int EmployeeCodeID, DateTime AssigningEndDate, AssigningsReasonsEnum EndAssigningReason, string EndAssigningReasonNotes = "")
        {
            Result            result       = new Result();
            BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL();
            Assignings        assigning    = new AssigningsDAL().GetActiveAssigningByEmployeeCodeID(EmployeeCodeID);

            if (assigning != null)
            {
                if (assigning.IsFinished)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                    return(result);
                }

                if (AssigningEndDate < assigning.AssigningStartDate)
                {
                    result            = new Result();
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString();

                    return(result);
                }

                assigning.AssigningEndDate     = AssigningEndDate;
                assigning.EndAssigningReasonID = (int)EndAssigningReason;
                assigning.IsFinished           = true;
                assigning.Notes           = EndAssigningReasonNotes;
                assigning.LastUpdatedBy   = this.LoginIdentity.EmployeeCodeID;
                assigning.LastUpdatedDate = DateTime.Now;
                this.AssigningID          = new AssigningsDAL().BreakAssigning(assigning);
                if (this.AssigningID != 0)
                {
                    #region Cancellation of all pending e vacations requests of employee after breaking last assigning of him
                    List <EVacationsRequests> PendingEVacationRequestsList = new EVacationsRequestsDAL().GetByEmployeeCodeID(EmployeeCodeID, (int)EVacationRequestStatusEnum.Pending);
                    foreach (var item in PendingEVacationRequestsList)
                    {
                        result = new EVacationsRequestsBLL().CancelEVacationRequest(item.EVacationRequestID, EVacationRequestStatusEnum.CancelledBySystem, Globalization.EVacationRequestCancelledBySystemBecauseOfBreakingLastAssigningText);
                    }
                    #endregion

                    #region Task 318: Service to Cancel EServicesProxies By System
                    try
                    {
                        result = new EServicesProxiesBLL()
                        {
                            LoginIdentity = this.LoginIdentity
                        }
                        .RevokeEServiceProxyByEmployeeCodeID(EmployeeCodeID, EServicesProxiesStatusEnum.CancelledBySystem, Globalization.EServiceProxyCancelledBySystemBecauseOfBreakingLastAssigningText);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
            }
            else
            {
                result.EnumType   = typeof(AssigningsValidationEnum);
                result.EnumMember = AssigningsValidationEnum.RejectedBecauseAssigningNotFound.ToString();
            }

            return(result);
        }