Exemple #1
0
        private async Task <ApplicantData> GetApplicantDataAsync(Shared.Enums.EServiceType serviceType, int requestId)
        {
            Shared.Enums.IdentificationType applicantIdentifierType = Shared.Enums.IdentificationType.EGN;
            string applicantIdentifier = "";
            string applicantName       = "";

            if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYCERTIFICATE)
            {
                RequestForCertificateOfDistraintOfProperty req = await _context.RequestForCertificateOfDistraintOfProperty
                                                                 .Where(x => x.Id == requestId)
                                                                 .FirstOrDefaultAsync();

                if (req != null)
                {
                    bool isCompany = String.IsNullOrWhiteSpace(req.PersonalIdentifier);
                    if (isCompany)
                    {
                        applicantIdentifierType = Shared.Enums.IdentificationType.BULSTAT;
                        applicantIdentifier     = req.IdentifierOfLegalEntity;
                        applicantName           = req.NameOfLegalEntity;
                    }
                    else
                    {
                        if (req.IsPersonalIdentifierTypeLnch == true)
                        {
                            applicantIdentifierType = Shared.Enums.IdentificationType.LNCH;
                        }
                        applicantIdentifier = req.PersonalIdentifier;
                        applicantName       = $"{req.FirstName ?? ""} {req.MiddleName ?? ""} {req.LastName ?? ""}";
                    }
                }
            }
            else if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYBYOWNERREPORT)
            {
                SeizedPropertyAvailabilityRequest req = await _context.SeizedPropertyAvailabilityRequest
                                                        .Include(x => x.RequestorPerson)
                                                        .Include(x => x.RequesterCompany)
                                                        .Where(x => x.Id == requestId)
                                                        .FirstOrDefaultAsync();

                if (req != null)
                {
                    if (req.RequestorPerson != null)
                    {
                        applicantIdentifier = req.RequestorPerson.IdentificationNumber;
                        applicantName       = $"{req.RequestorPerson.FirstName ?? ""} {req.RequestorPerson.MiddleName ?? ""} {req.RequestorPerson.LastName ?? ""}";
                    }
                    else if (req.RequesterCompany != null)
                    {
                        applicantIdentifierType = Shared.Enums.IdentificationType.BULSTAT;
                        applicantIdentifier     = req.RequesterCompany.Eik;
                        applicantName           = req.RequesterCompany.Name;
                    }
                }
            }

            ApplicantData data = new ApplicantData(applicantIdentifierType, applicantIdentifier, applicantName);

            return(data);
        }
Exemple #2
0
        public async Task <EServicePaymentRequestCreateModel> GeneratePaymentRequestAsync(Shared.Enums.EServiceType serviceType, int requestId)
        {
            // Взима данни на заявителя.
            ApplicantData applicantData = await GetApplicantDataAsync(serviceType, requestId);

            // Взеима данните за доставчик на ЕАУ, в случая Министерство на правосъдието.
            EServicesSettingsModel settings = await _eServiceSettingsService.GetEServiceSettingsAsync();

            PaymentRequestModel paymentRequest = CreatePaymentRequest(serviceType, settings, applicantData);

            paymentRequest = await SavePaymentRequestAsync(paymentRequest);

            EServicePaymentRequestCreateModel servicePaymentRequest = new EServicePaymentRequestCreateModel();

            servicePaymentRequest.EserviceTypeCode = serviceType.ToString();
            if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYCERTIFICATE)
            {
                servicePaymentRequest.SeizedPropertyCertificateRequestId = requestId;
            }
            else if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYBYOWNERREPORT)
            {
                servicePaymentRequest.SeizedPropertyReportRequestId = requestId;
            }
            servicePaymentRequest.PaymentRequestId = paymentRequest.AisPaymentId;
            servicePaymentRequest.StatusCode       = Shared.Enums.PaymentRequestStatus.NEW.ToString();

            EservicePaymentRequest entity = servicePaymentRequest.ToEntity();

            await _context.EservicePaymentRequest.AddAsync(entity);

            await _context.SaveChangesAsync();

            await AddEServicePaymentRequestStatusHistory(entity.Id, entity.StatusCode, entity.CreatedAt, null, null);

            servicePaymentRequest.Id = entity.Id;
            return(servicePaymentRequest);
        }
Exemple #3
0
        private PaymentRequestModel CreatePaymentRequest(Shared.Enums.EServiceType serviceType, EServicesSettingsModel settings, ApplicantData applicantData)
        {
            int     expirationDays = 0;
            decimal fee            = 0m;
            string  reason         = "";

            if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYCERTIFICATE)
            {
                expirationDays = settings.SeizedPropertyCertificateRequestExpirationDays.HasValue ? settings.SeizedPropertyCertificateRequestExpirationDays.Value : 0;
                fee            = settings.SeizedPropertyCertificateFee.HasValue ? settings.SeizedPropertyCertificateFee.Value : 0m;
                reason         = settings.SeizedPropertyCertificateReason;
            }
            else if (serviceType == Shared.Enums.EServiceType.SEIZEDPROPERTYBYOWNERREPORT)
            {
                expirationDays = settings.SeizedPropertyReportRequestExpirationDays.HasValue ? settings.SeizedPropertyReportRequestExpirationDays.Value : 0;
                fee            = settings.SeizedPropertyByOwnerReportFee.HasValue ? settings.SeizedPropertyByOwnerReportFee.Value : 0m;
                reason         = settings.SeizedPropertyReportReason;
            }

            PaymentRequestModel request = new PaymentRequestModel();

            request.ServiceProviderName                  = settings.ServiceProviderName;
            request.ServiceProviderBank                  = settings.ServiceProviderBank;
            request.ServiceProviderBic                   = settings.ServiceProviderBic;
            request.ServiceProviderIban                  = settings.ServiceProviderIban;
            request.Currency                             = settings.Currency;
            request.PaymentTypeCode                      = "1"; //Код на плащане. Да се разбере какъв може да бъде. Примерно "1"
            request.PaymentAmount                        = fee;
            request.PaymentReason                        = reason;
            request.ApplicantUinTypeId                   = (int)applicantData.applicantIdentifierType;
            request.ApplicantUin                         = applicantData.applicantIdentifier;
            request.ApplicantName                        = applicantData.applicantName;
            request.PaymentReferenceType                 = "1"; // Тип на документ (референтен документ за плащане). Да се разбере какъв може да бъде.
            request.PaymentReferenceNumber               = Guid.NewGuid().ToString();
            request.PaymentReferenceDate                 = DateTime.Now;
            request.ExpirationDate                       = DateTime.Now.AddDays(expirationDays);
            request.AdditionalInformation                = null;
            request.AdministrativeServiceUri             = null;
            request.AdministrativeServiceSupplierUri     = _settings.AdministrativeServiceSupplierUri;
            request.AdministrativeServiceNotificationUrl = string.IsNullOrWhiteSpace(settings.AdministrativeServiceNotificationUrl)
                ? _settings.AdministrativeServiceNotificationUrl
                : settings.AdministrativeServiceNotificationUrl;

            return(request);
        }