//public List<ChartsAxis> GetQualificationsBasedOnAssigningsAsRanksCategories(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID) //{ // try // { // List<int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID); // // Get actual employees Based On Assignings by date // List<vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList(); // List<int> EmployeesCodesIDs = new List<int>(); // ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID)); // List<EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs); // List<EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List<EmployeesQualificationsBLL>(); // ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID))); // EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID // && (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID) // && (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList(); // ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID)); // var query = ActualEmployeesBasedOnAssignings.GroupBy(x => x.RankCategoryName) // .Select(y => new // { // RankCategoryName = y.Key, // RecordCount = y.Count() // }).ToList(); // List<ChartsAxis> ChartAxisList = new List<ChartsAxis>(); // foreach (var item in query) // ChartAxisList.Add(new ChartsAxis { KeyName = item.RankCategoryName, Value = item.RecordCount }); // return ChartAxisList; // } // catch // { // throw; // } //} public IQueryable <EmployeesQualificationBasedOnAssigngingsDTO> GetQualificationsBasedOnAssigningsAsRanksCategoriesDetails(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID) { try { List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID); // Get actual employees Based On Assignings by date List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList(); List <int> EmployeesCodesIDs = new List <int>(); ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID)); List <EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs); List <EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List <EmployeesQualificationsBLL>(); ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID))); EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID && (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID) && (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList(); ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID)); var query = ActualEmployeesBasedOnAssignings.Select(y => new EmployeesQualificationBasedOnAssigngingsDTO(y.EmployeeCodeNo, y.EmployeeNameAr, y.OrganizationName, y.JobName, y.RankCategoryName, y.RankName, EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).QualificationDegree.QualificationDegreeName, EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).Qualification.QualificationName, EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).GeneralSpecialization.GeneralSpecializationName, y.Sorting )); return(query.AsQueryable()); } catch { throw; } }
public IQueryable <EmployeesDelegationsBasedOnAssigngingsDTO> GetEmployeesDelegationsBasedOnAssigningsAsRanksCategories(int DelegationTypeID, DateTime FromDate, DateTime ToDate, int OrganizationID) { try { List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID); DateTime FromDateGr = Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", FromDate.Day, FromDate.Month, FromDate.Year)), new CultureInfo("en-US")); DateTime ToDateGr = Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", ToDate.Day, ToDate.Month, ToDate.Year)), new CultureInfo("en-US")); List <vwActualEmployeesBasedOnAssignings> ActualEmployeesHaveDelegations = new List <vwActualEmployeesBasedOnAssignings>(); // Get actual employees Based On Assignings by date List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => // (FromDateGr.Date >= x.AssigningStartDate.Date && FromDateGr.Date <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) ( (FromDateGr >= x.AssigningStartDate && FromDateGr <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) || (ToDate >= x.AssigningStartDate && ToDate <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) || (FromDateGr >= x.AssigningStartDate && ToDate <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) || (FromDateGr <= x.AssigningStartDate && ToDate >= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) ) && OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList(); List <int> EmployeeCareerHistoryIDs = new List <int>(); ActualEmployeesBasedOnAssignings.ForEach(x => EmployeeCareerHistoryIDs.Add(x.EmployeeCareerHistoryID.Value)); List <DelegationsDetails> EmployeesDelegationsOfActualEmployeesList = new DelegationsDetailsDAL().GetEmployeesDelegationsByDate(FromDateGr, DelegationTypeID, EmployeeCareerHistoryIDs); var query = EmployeesDelegationsOfActualEmployeesList.Select(y => new EmployeesDelegationsBasedOnAssigngingsDTO(y.EmployeesCareersHistory.EmployeesCodes.EmployeeCodeNo, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).EmployeeNameAr, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).OrganizationName, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).JobName, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).RankCategoryName, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).RankName, y.Delegations.DelegationStartDate, y.Delegations.DelegationEndDate, y.Delegations.DelegationsTypes.DelegationTypeName, ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).Sorting )); return(query.AsQueryable()); } catch { throw; } }