public Employee Add(PeriodId periodId, string personnelNo, string firstName, string lastName, Dictionary <SharedEmployeeCustomFieldId, string> customFieldIds) { try { using (var tr = new TransactionScope()) { var period = periodRep.GetById(periodId); var employeeCustomFields = converter.GetSharedEmployeeCustomField(customFieldIds.Keys.ToList()); var employee = new Employee(personnelNo, period, firstName, lastName, employeeCustomFields.ToDictionary(e => e, e => customFieldIds[e.Id])); employeeRep.Add(employee); tr.Complete(); return(employee); } } catch (Exception exp) { var res = employeeRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
public EmployeeDTO GetEmployee(long periodId, string employeeNo) { var employee = employeeService.GetBy(new EmployeeId(employeeNo, new PeriodId(periodId))); var employeeDTO = employeeDTOMapper.MapToModel(employee); var employeeCustomFields = converter.GetSharedEmployeeCustomField(employee.CustomFieldValues.Keys.ToList()); employeeDTO.CustomFields = employeeCustomFields.Select( ec => new CustomFieldValueDTO { Id = ec.Id.Id, IsReadOnly = false, Name = ec.Name, Value = employee.CustomFieldValues[ec.Id] }).ToList(); return(employeeDTO); }
public RuleContracts.CalculationData Provide(Employee emp, out CalculationData calculationData, Calculation calculation, bool withCalculationPoint, CalculatorSession calculationSession) { //empRep.Attach(employee); var employee = empRep.GetBy(emp.Id); calculationData = empRep.ProvideDataForRule(employee, calculation.Id, withCalculationPoint); if (calculationSession.CalculationPoints != null && calculationSession.CalculationPoints.Any()) { calculationData.CalculationPoints.AddRange(calculationSession.CalculationPoints); } var res = new MITD.PMS.RuleContracts.CalculationData { Employee = new PMS.RuleContracts.Employee { FirstName = calculationData.employee.FirstName, LastName = calculationData.employee.LastName, EmployeeNo = calculationData.employee.Id.EmployeeNo }, CustomFields = (from k in pmsAdminService.GetSharedEmployeeCustomField( employee.CustomFieldValues.Select(m => m.Key).ToList()) join l in employee.CustomFieldValues on k.Id equals l.Key select new { k, l }).ToDictionary(j => j.k.DictionaryName, j => j.l.Value), JobPositions = calculationData.JobPositions.Select(jobPositionAndData => new JobPosition { Name = jobPositionAndData.Key.Name, DictionaryName = jobPositionAndData.Key.DictionaryName, Job = new Job { Name = jobPositionAndData.Value.Job.Name, DictionaryName = jobPositionAndData.Value.Job.DictionaryName }, Unit = new Unit { Id = jobPositionAndData.Value.Unit.Id.SharedUnitId.Id, ParentId = jobPositionAndData.Value.Unit.Parent != null ? jobPositionAndData.Value.Unit.Parent.Id.SharedUnitId.Id : 0, Name = jobPositionAndData.Value.Unit.Name, DictionaryName = jobPositionAndData.Value.Unit.DictionaryName, Indices = jobPositionAndData.Value.UnitIndices.ToDictionary( j => new UnitIndex { Name = j.Key.Name, DictionaryName = j.Key.DictionaryName, IsInquireable = j.Key.IsInquireable, //Group = // new JobIndexGroup { Name = j.Key.Group.Name, DictionaryName = j.Key.Group.DictionaryName }, CustomFields = (from k in pmsAdminService.GetSharedCutomFieldListForUnitIndex(j.Key.SharedUnitIndexId, j.Key.CustomFieldValues.Select(m => m.Key).ToList()) join l in j.Key.CustomFieldValues on k.Id equals l.Key select new { k, l }).ToDictionary(m => m.k.DictionaryName, m => m.l.Value) }, j => (j.Value != null ? new Tuple <PMS.RuleContracts.Employee, string>(new RuleContracts.Employee() { EmployeeNo = j.Value.Item1.Id.EmployeeNo, FirstName = j.Value.Item1.FirstName, LastName = j.Value.Item1.LastName }, j.Value.Item2) //j.Value.ToDictionary( // k => new PMS.RuleContracts.Employee // { // FirstName = k.Key.FirstName, // LastName = k.Key.LastName, // EmployeeNo = k.Key.Id.EmployeeNo // }, // k => k.Value.Select(f => // new Inquiry // { // JobPosition = // new InquirerJobPosition // { // Name = f.JobPosition.Name, // DictionaryName = f.JobPosition.DictionaryName, // JobPositionLevel = (int)jobPositionAndData.Key.ConfigurationItemList.Single(cil => cil.Id == f.Point.ConfigurationItemId).InquirerJobPositionLevel // }, // Value = f.Point.JobIndexValue // }).ToList()) : null)) }, CustomFields = (from k in pmsAdminService.GetSharedCutomFieldListForJob(jobPositionAndData.Value.Job.SharedJob.Id, jobPositionAndData.Value.CustomFields.Select( m => m.JobCustomFieldId.SharedJobCustomFieldId).ToList()) join l in jobPositionAndData.Value.CustomFields on k.Id equals l.JobCustomFieldId.SharedJobCustomFieldId select new { k, l }).ToDictionary(j => j.k.DictionaryName, j => j.l.JobCustomFieldValue), Indices = jobPositionAndData.Value.Indices.ToDictionary( j => new JobIndex { Name = j.Key.Name, DictionaryName = j.Key.DictionaryName, IsInquireable = j.Key.IsInquireable, Group = new JobIndexGroup { Name = j.Key.Group.Name, DictionaryName = j.Key.Group.DictionaryName }, CustomFields = (from k in pmsAdminService.GetSharedCutomFieldListForJobIndex(j.Key.SharedJobIndexId, j.Key.CustomFieldValues.Select(m => m.Key).ToList()) join l in j.Key.CustomFieldValues on k.Id equals l.Key select new { k, l }).ToDictionary(m => m.k.DictionaryName, m => m.l.Value) }, j => (j.Value != null ? j.Value.ToDictionary( k => new PMS.RuleContracts.Employee { FirstName = k.Key.FirstName, LastName = k.Key.LastName, EmployeeNo = k.Key.Id.EmployeeNo }, k => k.Value.Select(f => new Inquiry { JobPosition = new InquirerJobPosition { Name = f.JobPosition.Name, DictionaryName = f.JobPosition.DictionaryName, JobPositionLevel = (int) jobPositionAndData.Key.ConfigurationItemList.Single( cil => cil.Id == f.Point.ConfigurationItemId && cil.Id.InquirerJobPositionId.SharedJobPositionId == f.JobPosition.Id).InquirerJobPositionLevel }, Value = f.Point.JobIndexValue }).ToList()) : null)) }).ToList() }; var ruleResult = addPreviousEmployeePointsToCalculationData(calculationData, calculationSession.CalculationPoints); res.Points = ruleResult; res.PathNo = calculationSession.PathNo; return(res); }