public JobIndex AddJobIndex(PeriodId periodId, AbstractJobIndexId groupId, SharedJobIndexId jobIndexId, IDictionary <SharedJobIndexCustomFieldId, string> customFieldValues, bool isInquireable, int calculationOrder, long calculationLevel) { try { using (var tr = new TransactionScope()) { var period = periodRep.GetById(periodId); var sharedJob = pmsAdminService.GetSharedJobIndex(jobIndexId); var id = jobIndexRep.GetNextId(); if (groupId == null) { throw new ArgumentException("groupId is null"); } var group = jobIndexRep.GetJobIndexGroupById(groupId); var jobIndex = new JobIndex(id, period, sharedJob, group, isInquireable, calculationLevel, calculationOrder); var validateCustomFldValues = getSharedJobIndexCustomFields(jobIndexId, customFieldValues); jobIndex.UpdateCustomFields(validateCustomFldValues); jobIndexRep.Add(jobIndex); tr.Complete(); return(jobIndex); } } catch (Exception exp) { var res = jobIndexRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
public SubordinatesResultDTO GetTrainingNeedEmployeeInFieldInPeriod(long periodIdParam, long jobindexId) { var periodId = new PeriodId(periodIdParam); var period = periodRep.GetById(periodId); var res = new SubordinatesResultDTO { PeriodName = period.Name, PeriodTimeLine = "از تاریخ " + PDateHelper.GregorianToHijri(period.StartDate, false) + " تا تاریخ " + PDateHelper.GregorianToHijri(period.EndDate.Date, false), //TotalUnitPoint = finalUnitPoint == null ? (0).ToString() : finalUnitPoint.Value.ToString(CultureInfo.InvariantCulture), Subordinates = new List <EmployeeResultDTO>() }; var calculation = calculationRepository.GetDeterministicCalculation(period); var employeeIds = jobIndexPointRepository.GetJobIndexPointByLimitPoint(calculation.Id, 50).Where(j => j.JobIndexId.Id == jobindexId).Select(j => j.EmployeeId); foreach (var employeeId in employeeIds) { var employee = employeeRepository.GetBy(employeeId); var employeeIndexPoints = jobIndexPointRepository.GetBy(calculation.Id, employee.Id); var employeeResult = new EmployeeResultDTO { EmployeeFullName = employee.FullName, EmployeeNo = employeeId.EmployeeNo, //EmployeeJobPositionName = jobPositionNames, TotalPoint = employee.FinalPoint.ToString(CultureInfo.InvariantCulture), }; res.Subordinates.Add(employeeResult); } return(res); }
public void RemoveInquirer(PeriodId periodId, SharedUnitId unitId, EmployeeId employeeId) { try { using (var tr = new TransactionScope()) { var unit = unitRep.GetBy(new UnitId(periodId, unitId)); var empl = unit.ConfigurationItemList.SingleOrDefault(c => c.Id.InquirerId == employeeId); if (empl != null) { unit.DeleteInquirer(empl); } tr.Complete(); } } catch (Exception exp) { var res = unitRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
public Task <IReadOnlyList <IPeriodOperation> > SearchOperation(string filter) { if (filter.IsEmpty()) { return(Task.FromResult((IReadOnlyList <IPeriodOperation>) new List <IPeriodOperation>())); } var filterElements = filter.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return(Task.FromResult((IReadOnlyList <IPeriodOperation>)filterElements .Aggregate(_operations.SelectMany(a => a.Value).ToList(), Filter))); List <IPeriodOperation> Filter(IReadOnlyList <IPeriodOperation> operations, string filterCriteria) { return(operations .Where(operation => operation.Label.Match(filterCriteria) || operation.Amount.ToString(frCulture).Match(filterCriteria) || operation.Pair.Match(filterCriteria) || PeriodId.From(operation.PeriodId).ToPeriodName().ToString().Split(' ')[0].Match(filterCriteria) || operation.Category.Match(filterCriteria) || operation.Type.Match(filterCriteria)) .ToList()); } double GetNumber(string source) => double.TryParse(source, out var result) ? result : -1; }
public void be_equatable() { var id1 = PeriodId.From(2, 2019); var id2 = PeriodId.From(PeriodName.From(2, 2019)); id1.Should().Be(id2); }
public JobIndexGroup AddJobIndexGroup(PeriodId periodId, AbstractJobIndexId parentId, string name, string dictionaryName) { try { using (var tr = new TransactionScope()) { var id = jobIndexRep.GetNextId(); var period = periodRep.GetById(periodId); JobIndexGroup parent = null; if (parentId != null) { parent = jobIndexRep.GetJobIndexGroupById(new AbstractJobIndexId(parentId.Id)); } var jobIndexGroup = new JobIndexGroup(id, period, parent, name, dictionaryName); jobIndexRep.Add(jobIndexGroup); tr.Complete(); return(jobIndexGroup); } } catch (Exception exp) { var res = jobIndexRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
protected CalculationPoint(CalculationPointId id, Period period, Calculation calculation, string name, decimal value, bool isFinal = false) : base() { this.value = value; if (id == null) { throw new ArgumentNullException("calculationPointId"); } this.id = id; if (period == null || period.Id == null) { throw new ArgumentNullException("period"); } this.periodId = period.Id; if (calculation == null || calculation.Id == null) { throw new ArgumentNullException("employee"); } this.calculationId = calculation.Id; this.isFinal = isFinal; this.name = name; }
public void be_created_from_periodName() { var periodName = PeriodName.From(1, 2018); var periodId = PeriodId.From(periodName); periodId.Value.Should().Be("2018-01"); }
public Claim(ClaimId claimId, Period period, string employeeNo, string title, DateTime claimDate, ClaimTypeEnum claimTypeId, string request) { period.CheckAddClaim(); if (claimId == null) { throw new ArgumentNullException("claimId"); } if (period == null) { throw new ArgumentNullException("period"); } id = claimId; this.periodId = period.Id; if (string.IsNullOrWhiteSpace(employeeNo)) { throw new ClaimArgumentException("Claim", "EmployeeNo"); } this.employeeNo = employeeNo; this.title = title; this.claimDate = claimDate; this.claimTypeId = claimTypeId; this.request = request; state = new ClaimOpenedState(); }
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 void RemoveOperation(PeriodId periodId, OperationId operationId) { if (_operations.ContainsKey(periodId.Value)) { _operations[periodId.Value].RemoveAll(o => o.OperationId == operationId.Value); } }
public AddSpending(PeriodId periodId, Amount amount, Label label, Pair pair, SpendingCategory category) { PeriodId = periodId; Amount = amount; Label = label; Pair = pair; Category = category; }
public decimal GetEmployeeFinalPointBy(PeriodId periodId, string employeeNo, CalculationId calculationId) { var employeePoint = repEmp.Find(e => e.PeriodId == periodId && e.CalculationId == calculationId && e.IsFinal && e.EmployeeId.EmployeeNo == employeeNo) .SingleOrDefault(); return(employeePoint == null ? 0 : employeePoint.Value); }
public AddRecipe(PeriodId periodId, Amount amount, Label label, Pair pair, RecipeCategory category) { PeriodId = periodId; Amount = amount; Label = label; Pair = pair; Category = category; }
public Task <IReadOnlyList <IPeriodOperation> > GetAllOperation(PeriodId periodId) { IReadOnlyList <IPeriodOperation> result = _operations.ContainsKey(periodId.Value) ? _operations[periodId.Value] : new List <IPeriodOperation>(); return(Task.FromResult(result)); }
public ChangeSpending(PeriodId periodId, OperationId operationId, Amount amount = null, Label label = null, Pair pair = null, SpendingCategory category = null) { PeriodId = periodId; OperationId = operationId; Amount = amount; Label = label; Pair = pair; Category = category; }
public void CompleteCopyingBasicData(PeriodId periodId, PeriodState preState) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); period.CompleteCopyingBasicData(periodManagerService, preState); scope.Complete(); } }
public void CompleteInquiry(PeriodId periodId) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); period.CompleteInquiry(periodManagerService); scope.Complete(); } }
public void StartConfirmation(PeriodId periodId) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); period.StartConfirmation(periodManagerService); scope.Complete(); } }
public async Task <IActionResult> AddRecipe([FromBody] NewRecipe input) { return(await SendCommandAsync(new AddRecipe( PeriodId.From(input.PeriodId), Amount.From(input.Amount), Label.From(input.Label), Pair.From(input.Pair), RecipeCategory.From(input.Category)))); }
public List <JobId> GetAllJobIdList(PeriodId periodId) { using (var tr = new TransactionScope()) { var jobId = jobRep.GetAllJobIdList(periodId); tr.Complete(); return(jobId); } }
public async Task <IActionResult> AddSpending([FromBody] Spending input) { return(await SendCommandAsync(new AddSpending( PeriodId.From(input.PeriodId), Amount.From(input.Amount), Label.From(input.Label), Pair.From(input.Pair), SpendingCategory.From(input.Category)))); }
public void FinishClaiming(PeriodId periodId) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); period.FinishClaiming(periodManagerService); scope.Complete(); } }
public async Task <IActionResult> ChangeRecipe([FromBody] UpdateRecipe input) { return(await SendCommandAsync(new ChangeRecipe( PeriodId.From(input.PeriodId), OperationId.From(input.OperationId), Amount.From(input.Amount), Label.From(input.Label), Pair.From(input.Pair), RecipeCategory.From(input.Category)))); }
public List <InquiryJobIndexPoint> GetAllBy(PeriodId periodId, EmployeeId inquirerEmployeeId, AbstractJobIndexId jobIndexId) { return (rep.Find( i => i.ConfigurationItemId.InquirerId.PeriodId == periodId && i.ConfigurationItemId.InquirerId.EmployeeNo == inquirerEmployeeId.EmployeeNo && i.JobIndexId == jobIndexId) .ToList()); }
public InquiryInitializingProgress GetPeriodInitializeInquiryState(PeriodId periodId) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); var res = period.GetInitializeInquiryProgress(periodManagerService); scope.Complete(); return(res); } }
public BasicDataCopyingProgress GetPeriodCopyingStateProgress(PeriodId periodId) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); var res = period.GetCopyingStateProgress(periodManagerService); scope.Complete(); return(res); } }
public void ChangePeriodActiveStatus(PeriodId periodId, bool active) { using (var scope = new TransactionScope()) { var period = periodRep.GetById(periodId); setInitData(period); period.ChangeActiveStatus(periodManagerService, active); scope.Complete(); } }
public AbstractUnitIndex(AbstractUnitIndexId abstractUnitIndexId, PeriodId periodId) { if (abstractUnitIndexId == null) { throw new ArgumentNullException("abstractUnitIndexId"); } if (periodId == null) { throw new ArgumentNullException("periodId"); } id = abstractUnitIndexId; this.periodId = periodId; }
public IEnumerable <JobPositionInPeriodDTO> GetJobPositions(long periodIdParam) { var periodId = new PeriodId(periodIdParam); var jobPositions = jobPositionRep.GetJobPositions(periodId); var res = jobPositions.Select(u => jobPositionInPeriodDTOMapper.MapToModel(u)).ToList(); res.ForEach(d => { d.UnitName = _unitRepository.GetBy(new UnitId(periodId, new SharedUnitId(d.Unitid))).Name; d.JobName = _jobRepository.GetById(new JobId(periodId, new SharedJobId(d.JobId))).Name; d.Name += "-" + d.UnitName; }); return(res); }