public List <UnitInquiryConfigurationItem> Configure(Unit unit) { // var childs = _unitRep.GetAllUnitByParentId(unit.Id); // var siblings = _unitRep.Find(j => j.Parent == unit.Parent && j.Id.PeriodId.Id == unit.Id.PeriodId.Id); // var inquirersunits = childs.ToDictionary(j => j, u => UnitLevel.Childs); // inquirersunits = inquirersunits.Concat(siblings.ToDictionary(j => j, u => UnitLevel.Siblings)).ToDictionary(s => s.Key, s => s.Value); // if (unit.Parent != null) // inquirersunits.Add(unit.Parent, UnitLevel.Parents); ///////////////////////////////////////////////////////////////////////////////////////// // var inquirers = new Dictionary<UnitEmployee, UnitLevel>(); //foreach (var jp in inquirersunits) // inquirers = inquirers.Concat(jp.Key.Employees.ToDictionary(e => e, u => jp.Value)).ToDictionary(s => s.Key, s => s.Value); //todo New Code var parentUnit = unit.Parent; var jobpositions = _jobPositionRepository.Find( c => c.UnitId.SharedUnitId == parentUnit.SharedUnit.Id && c.UnitId.PeriodId.Id == parentUnit.Id.PeriodId.Id); var res = new List <UnitInquiryConfigurationItem>(); foreach (var jobposition in jobpositions) { jobposition.ConfigeInquirer(_jobPositionInquiryConfiguratorService, false); foreach (var empl in jobposition.Employees) { //res.Add( // new UnitInquiryConfigurationItem( // new UnitInquiryConfigurationItemId(parentUnit.Id, empl.EmployeeId, unit.Id) // , unit, true, true)); } } //var res = new List<UnitInquiryConfigurationItem>(); //foreach (var inquirySubject in unit.Employees) //{ // foreach (var inquirer in inquirers) // res.Add( // new UnitInquiryConfigurationItem( // new UnitInquiryConfigurationItemId(inquirer.Key.Unit.Id, inquirer.Key.EmployeeId, unit.Id, // inquirySubject.EmployeeId), unit, true, true, inquirer.Value)); //} return(res); }
public List <JobPositionInquiryConfigurationItem> Configure(JobPosition jobPosition) { var childs = jobPositionRep.Find(j => j.Parent.Id == jobPosition.Id); var inquirersjobPositions = childs.ToDictionary(j => j, u => JobPositionLevel.Childs); //360 daraje //var siblings = jobPositionRep.Find(j => j.Parent == jobPosition.Parent && j.Id.PeriodId.Id == jobPosition.Id.PeriodId.Id); //inquirersjobPositions = inquirersjobPositions.Concat(siblings.ToDictionary(j => j, u => JobPositionLevel.Siblings)).ToDictionary(s => s.Key, s => s.Value); //irisl inquirersjobPositions.Add(jobPosition, JobPositionLevel.None); ///////////////////////////////////////////////////////////////////////////////////////// if (jobPosition.Parent != null) { inquirersjobPositions.Add(jobPosition.Parent, JobPositionLevel.Parents); } ///////////////////////////////////////////////////////////////////////////////////////// var inquirers = new Dictionary <JobPositionEmployee, JobPositionLevel>(); foreach (var jp in inquirersjobPositions) { inquirers = inquirers.Concat(jp.Key.Employees.ToDictionary(e => e, u => jp.Value)).ToDictionary(s => s.Key, s => s.Value); } var res = new List <JobPositionInquiryConfigurationItem>(); foreach (var inquirySubject in jobPosition.Employees) { foreach (var inquirer in inquirers) { res.Add( new JobPositionInquiryConfigurationItem( new JobPositionInquiryConfigurationItemId(inquirer.Key.JobPosition.Id, inquirer.Key.EmployeeId, jobPosition.Id, inquirySubject.EmployeeId), jobPosition, true, true, inquirer.Value)); } } return(res); }