Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task<BillingCodesValidationResult> BillingCodesCheck(ElectronicI9 electronicI9)
- {
- var generalParametersDisplayRules = await _displayRulesRepository.GetGeneralParametersDisplayRulesForReportOrderAsync(electronicI9.ClientId);
- var client = await _clientService.GetClientAsync(electronicI9.ClientId);
- var billingCodeWebNames = await _billingCodeRepository.GetBillingCodeWebNameAsync(electronicI9.ClientId) ?? new BillingCodeWebName();
- var allowedNumber = client.AllowedBillingCodesTextBoxNumber + client.AllowedBillingCodesDropDownNumber;
- var billingCodes = new List<BillingCodeValidationResult>
- {
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName1, Value = electronicI9.BillingInfo.BillingCodeNum1 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName2, Value = electronicI9.BillingInfo.BillingCodeNum2 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName3, Value = electronicI9.BillingInfo.BillingCodeNum3 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName4, Value = electronicI9.BillingInfo.BillingCodeNum4 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName5, Value = electronicI9.BillingInfo.BillingCodeNum5 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName6, Value = electronicI9.BillingInfo.BillingCodeNum6 },
- new BillingCodeValidationResult {Name = billingCodeWebNames.BillingCodeWebName7, Value = electronicI9.BillingInfo.BillingCodeNum7 }
- };
- var billingCodeChecked = new bool[billingCodes.Count];
- for (int i = 1; i <= client.AllowedBillingCodesDropDownNumber; i++)
- {
- var billingCodesGroup = await _billingCodeRepository.GetBillingCodesAsync(client.ClientId, i);
- var billingCodeValues = billingCodesGroup.Select(b => b.BillingCodeName);
- if (!billingCodeValues.Contains(billingCodes[i - 1].Value))
- {
- billingCodeChecked[i - 1] = true;
- }
- }
- var firstBillingCodeInput = billingCodes[client.AllowedBillingCodesDropDownNumber];
- firstBillingCodeInput.Is6NumCheckValid = !(generalParametersDisplayRules.IsBillingCode6Num && !Regex.IsMatch(firstBillingCodeInput.Value, "^(\\d{6})$"));
- firstBillingCodeInput.Is8NumCheckValid = !(generalParametersDisplayRules.IsBillingCode8Num && !Regex.IsMatch(firstBillingCodeInput.Value, "^(\\d{4}\\-\\d{4})$"));
- var billingCodeRequiredAllCheck = true;
- if (generalParametersDisplayRules.IsBillingCodeRequiredAll)
- {
- for (int i = 0; i < billingCodes.Count && i < allowedNumber; i++)
- {
- if (string.IsNullOrEmpty(billingCodes[i].Value))
- {
- billingCodeRequiredAllCheck = false;
- }
- }
- }
- var billingCodesRequiredList = new[]
- {
- generalParametersDisplayRules.IsBillingCode1Required,
- generalParametersDisplayRules.IsBillingCode2Required,
- generalParametersDisplayRules.IsBillingCode3Required,
- generalParametersDisplayRules.IsBillingCode4Required,
- generalParametersDisplayRules.IsBillingCode5Required,
- generalParametersDisplayRules.IsBillingCode6Required,
- generalParametersDisplayRules.IsBillingCode7Required
- };
- for (int i = 0; i < billingCodesRequiredList.Length; i++)
- {
- var currentNumber = i + 1;
- billingCodes[i].IsRequiredCheckValid = !(billingCodesRequiredList[i]
- && allowedNumber >= currentNumber
- && string.IsNullOrEmpty(billingCodes[i].Value))
- && !billingCodeChecked[i];
- billingCodes[i].IsNumericCheckValid = !(generalParametersDisplayRules.IsBillingCodeNumeric
- && allowedNumber >= currentNumber
- && this.IsNotNumeric(electronicI9.BillingInfo.BillingCodeNum1));
- }
- return new BillingCodesValidationResult
- {
- IsRequiredAllCheckValid = billingCodeRequiredAllCheck,
- BillingCodes = billingCodes
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement