internal AssigningsReasonsBLL MapAssigningReason(AssigningsReasons AssigningReason) { try { AssigningsReasonsBLL AssigningReasonBLL = null; if (AssigningReason != null) { AssigningReasonBLL = new AssigningsReasonsBLL() { AssigningReasonID = AssigningReason.AssigningReasonID, AssigningReasonName = AssigningReason.AssigningReasonName }; } return(AssigningReasonBLL); } catch { throw; } }
public Result AssignEmployeeUnderManager() { try { Result result; //Result result = base.Add(); //if (result != null) // return result; //int EmployeeCodeID = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID; //DateTime StartDate = this.AssigningStartDate; //DateTime EndDate = this.AssigningEndDate ?? DateTime.Now.Date; #region Validate if the placement period finished or not result = CommonHelper.IsValidToCompleteEmployeesPlacement(); if (result != null) { return(result); } #endregion #region Validate if the employee has active Assigning or not BaseAssigningsBLL ActiveEmployeeAssigning = new EmployeesCodesBLL().GetAssigningsByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID).FirstOrDefault(x => x.IsFinished == false); if (ActiveEmployeeAssigning != null) { result = new Result(); result.Entity = ActiveEmployeeAssigning; result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString(); return(result); } #endregion AssigningsReasonsBLL AssigningReason = GetLastAssigningEndReasonsByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); Assignings assigning = new Assignings(); assigning.AssigningTypID = (int)AssigningsTypesEnum.Internal; assigning.AssigningReasonID = AssigningReason != null ? AssigningReason.AssigningReasonID : (int)AssigningsReasonsEnum.BasedOnWorkNeeds; assigning.AssigningStartDate = DateTime.Now.Date; assigning.ManagerCodeID = this.Manager.EmployeeCodeID; assigning.OrganizationID = this.Organization.OrganizationID; assigning.JobID = this.Job.JobID; assigning.EmployeeCareerHistoryID = this.EmployeeCareerHistory?.EmployeeCareerHistoryID; assigning.CreatedBy = this.LoginIdentity.EmployeeCodeID; assigning.CreatedDate = DateTime.Now; this.AssigningID = new AssigningsDAL().Insert(assigning); if (this.AssigningID != 0) { // this to get info of employee EmployeesCodesBLL EmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode != null ? this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID : 0); // this to get info of manager EmployeesCodesBLL ManagerCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.Manager.EmployeeCodeID); if (EmployeeCodeBLL != null) { SMSLogsBLL SMSLogBLL = new SMSLogsBLL() { BusinssSubCategory = BusinessSubCategoriesEnum.OrganizationStructure, MobileNo = EmployeeCodeBLL.Employee.EmployeeMobileNo, DetailID = 0, Message = string.Format(Globalization.SMSEmployeeAlreadyAssignedUnderManagerMessageText, EmployeeCodeBLL.Employee.FirstNameAr + " " + EmployeeCodeBLL.Employee.LastNameAr, new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(this.Organization.OrganizationID), ManagerCodeBLL.Employee.EmployeeNameAr), CreatedBy = this.LoginIdentity, CreatedDate = DateTime.Now, }; new SMSBLL().SendSMS(SMSLogBLL); } result = new Result(); result.Entity = this; result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.Done.ToString(); } return(result); } catch (Exception ex) { throw ex; } }