public async Task UpdateAmountAsync(Guid OverdraftDetailID, decimal Amount, List <ConceptRelationUpdateAmountDTO> ConceptRelationsAmountApplied,
                                            Guid instanceID, Guid identityWorkID)
        {
            var parameters = new UpdateAmountConceptDetailParams()
            {
                Amount                        = Amount,
                OverdraftDetailID             = OverdraftDetailID,
                ConceptRelationsAmountApplied = ConceptRelationsAmountApplied,
                InstanceID                    = instanceID,
                IdentityWorkID                = identityWorkID
            };

            var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                            new Uri($"{_cotorraUri}/CalculateFormula"), new object[] { parameters }).ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                return(i.Result);
            });


            return;
        }
예제 #2
0
        public async Task UpdateAmountAsync(UpdateAmountConceptDetailParams parameters)
        {
            Guid    OverdraftDetailID = parameters.OverdraftDetailID;
            Decimal Amount            = parameters.Amount;
            List <ConceptRelationUpdateAmountDTO> ConceptRelationsAmountApplied = parameters.ConceptRelationsAmountApplied;
            Guid identityWorkID = parameters.IdentityWorkID;
            Guid instanceID     = parameters.InstanceID;


            var ids = ConceptRelationsAmountApplied.Select(x => x.ID);
            var relationDetailDB  = _mgrEmployeeConceptsRelationDetail.FindByExpressionAsync(x => ids.Contains(x.ID) && x.InstanceID == instanceID, identityWorkID);
            var overdraftdetailDB = _clientOverdraftDetail.FindByExpressionAsync(x => x.ID == OverdraftDetailID && x.InstanceID == instanceID, identityWorkID);

            var details = (await relationDetailDB);

            details.ForEach(item =>
            {
                item.AmountApplied = ConceptRelationsAmountApplied.FirstOrDefault(x => x.ID == item.ID) != null ? ConceptRelationsAmountApplied.FirstOrDefault(x => x.ID == item.ID).AmountApplied : 0;
                item.IsAmountAppliedCapturedByUser = ConceptRelationsAmountApplied.FirstOrDefault(x => x.ID == item.ID) != null ? ConceptRelationsAmountApplied.FirstOrDefault(x => x.ID == item.ID).IsAmountAppliedCapturedByUser : false;
            });

            var overDetails = (await overdraftdetailDB);

            overDetails.ForEach(item =>
            {
                item.Amount = Amount;
                item.IsTotalAmountCapturedByUser = details.Any(x => x.IsAmountAppliedCapturedByUser);
            });


            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                await _mgrEmployeeConceptsRelationDetail.UpdateAsync(details, identityWorkID);

                await _clientOverdraftDetail.UpdateAsync(overDetails, identityWorkID);

                scope.Complete();
            }
        }