コード例 #1
0
        public async Task <PagedResultOutput <AddressListDto> > GetAddresses(GetAddressesInput input)
        {
            if (!input.OwnerId.HasValue || input.OwnerType.Length == 0)
            {
                throw new UserFriendlyException("MissingParameters");
            }
            IQueryable <Address> all     = this._addressRepository.GetAll();
            IQueryable <Address> ownerId =
                from p in all
                where p.OwnerId == input.OwnerId.Value
                select p;
            IQueryable <Address> addresses = ownerId.WhereIf <Address>(!string.IsNullOrEmpty(input.OwnerType), (Address p) => p.OwnerType == input.OwnerType);
            int num = await addresses.CountAsync <Address>();

            List <Address> listAsync = await addresses.OrderBy <Address>(input.Sorting, new object[0]).PageBy <Address>(input).ToListAsync <Address>();

            return(new PagedResultOutput <AddressListDto>(num, listAsync.MapTo <List <AddressListDto> >()));
        }
コード例 #2
0
        public async Task <ActionResult> Payeezy(FormCollection formFields)
        {
            int       value;
            string    str;
            Guid      guid;
            string    str1;
            bool      flag;
            PayNowDto payNowDto = new PayNowDto();

            try
            {
                int?impersonatorTenantId = this.AbpSession.ImpersonatorTenantId;
                if (impersonatorTenantId.HasValue)
                {
                    impersonatorTenantId = this.AbpSession.ImpersonatorTenantId;
                    value = impersonatorTenantId.Value;
                }
                else
                {
                    value = this.AbpSession.GetTenantId();
                }
                int num = value;
                TenantSettingsEditDto allSettingsByTenantId = await this._tenantSettingsAppService.GetAllSettingsByTenantId(num);

                long num1 = long.Parse(formFields["invoiceId"]);
                decimal.Parse(formFields["invoiceAmount"]);
                decimal num2    = decimal.Parse(formFields["paymentAmount"]);
                Invoice invoice = await this._invoiceAppService.GetInvoice(num1);

                if (invoice == null || invoice.TenantId != num)
                {
                    if (invoice != null)
                    {
                        throw new Exception("SecurityViolation");
                    }
                    throw new Exception("InvoiceIsNull");
                }
                payNowDto.x_invoice_num = invoice.Number;
                payNowDto.x_po_num      = invoice.PONumber;
                payNowDto.x_reference_3 = invoice.Number;
                ICustomerAppService    customerAppService = this._customerAppService;
                NullableIdInput <long> nullableIdInput    = new NullableIdInput <long>()
                {
                    Id = new long?(invoice.CustomerId)
                };
                GetCustomerForEditOutput customerForEdit = await customerAppService.GetCustomerForEdit(nullableIdInput);

                PayNowDto payNowDto1 = payNowDto;
                string[]  strArrays  = new string[7];
                long      id         = invoice.Id;
                strArrays[0] = id.ToString();
                strArrays[1] = "|";
                long?impersonatorUserId = customerForEdit.Customer.Id;
                id                 = impersonatorUserId.Value;
                strArrays[2]       = id.ToString();
                strArrays[3]       = "|";
                strArrays[4]       = num.ToString();
                strArrays[5]       = "|";
                impersonatorUserId = this.AbpSession.ImpersonatorUserId;
                if (impersonatorUserId.HasValue)
                {
                    impersonatorUserId = this.AbpSession.ImpersonatorUserId;
                    id  = impersonatorUserId.Value;
                    str = id.ToString();
                }
                else
                {
                    impersonatorUserId = this.AbpSession.UserId;
                    if (impersonatorUserId.HasValue)
                    {
                        impersonatorUserId = this.AbpSession.UserId;
                        id  = impersonatorUserId.Value;
                        str = id.ToString();
                    }
                    else
                    {
                        impersonatorUserId = this.AbpSession.UserId;
                        str = impersonatorUserId.ToString();
                    }
                }
                strArrays[6]         = str;
                payNowDto1.x_cust_id = string.Concat(strArrays);
                payNowDto.x_email    = customerForEdit.Customer.Email;
                if (customerForEdit.Customer.BusinessName != null && customerForEdit.Customer.BusinessName.ToString().Length > 0)
                {
                    payNowDto.x_company = customerForEdit.Customer.BusinessName;
                }
                if (customerForEdit.Customer.FirstName != null && customerForEdit.Customer.FirstName.ToString().Length > 0)
                {
                    payNowDto.x_first_name = customerForEdit.Customer.FirstName.ToString();
                }
                if (customerForEdit.Customer.LastName != null && customerForEdit.Customer.LastName.ToString().Length > 0)
                {
                    payNowDto.x_last_name = customerForEdit.Customer.LastName.ToString();
                }
                PayNowDto str2 = payNowDto;
                impersonatorUserId = customerForEdit.Customer.Id;
                id = impersonatorUserId.Value;
                str2.x_customer_tax_id = id.ToString();
                impersonatorUserId     = invoice.CustomerAddressId;
                if (impersonatorUserId.HasValue)
                {
                    impersonatorUserId = invoice.CustomerAddressId;
                    if (impersonatorUserId.Value > (long)0)
                    {
                        IGenericAppService genericAppService = this._genericAppService;
                        GetAddressesInput  getAddressesInput = new GetAddressesInput();
                        impersonatorUserId          = customerForEdit.Customer.Id;
                        getAddressesInput.OwnerId   = new long?(impersonatorUserId.Value);
                        getAddressesInput.OwnerType = "Customer";
                        PagedResultOutput <AddressListDto> addresses = await genericAppService.GetAddresses(getAddressesInput);

                        int num3 = 0;
                        while (num3 < addresses.Items.Count)
                        {
                            long id1 = (long)addresses.Items[num3].Id;
                            impersonatorUserId = invoice.CustomerAddressId;
                            flag = (id1 == impersonatorUserId.GetValueOrDefault() ? impersonatorUserId.HasValue : false);
                            if (!flag)
                            {
                                num3++;
                            }
                            else
                            {
                                payNowDto.x_address  = addresses.Items[num3].PrimaryAddress;
                                payNowDto.x_city     = addresses.Items[num3].City;
                                payNowDto.x_zip      = addresses.Items[num3].PostalCode;
                                impersonatorTenantId = addresses.Items[num3].CountryRegionId;
                                if (!impersonatorTenantId.HasValue)
                                {
                                    break;
                                }
                                IGenericAppService genericAppService1 = this._genericAppService;
                                impersonatorTenantId = addresses.Items[num3].CountryRegionId;
                                int?nullable = new int?(impersonatorTenantId.Value);
                                impersonatorTenantId = null;
                                ListResultOutput <CountryRegionInCountryListDto> countryRegions = genericAppService1.GetCountryRegions(nullable, impersonatorTenantId);
                                if (countryRegions.Items.Count != 1)
                                {
                                    break;
                                }
                                payNowDto.x_state = countryRegions.Items[0].Code;
                                break;
                            }
                        }
                    }
                }
                Tenant byIdAsync = await this._tenantManager.GetByIdAsync(num);

                string tenancyName = byIdAsync.TenancyName;
                string str3        = tenancyName;
                string str4        = tenancyName;
                str4      = str3;
                byIdAsync = await this._tenantManager.FindByTenancyNameAsync(str4);

                string    siteRootAddress = this._webUrlService.GetSiteRootAddress(str4);
                PayNowDto payNowDto2      = payNowDto;
                object[]  objArray        = new object[] { siteRootAddress, "Mpa/Settings/GetLogoById?logoId=", null, null, null };
                guid                            = (allSettingsByTenantId.Logo.InvoiceImageId.HasValue ? allSettingsByTenantId.Logo.InvoiceImageId.Value : Guid.Empty);
                objArray[2]                     = guid;
                objArray[3]                     = "&logoType=header&viewContrast=light&t=";
                id                              = Clock.Now.Ticks;
                objArray[4]                     = id.ToString();
                payNowDto2.x_logo_url           = string.Concat(objArray);
                payNowDto.x_receipt_link_url    = string.Concat(siteRootAddress, "Pay/PayeezyResponse");
                payNowDto.x_receipt_link_method = "AUTO-POST";
                payNowDto.x_receipt_link_text   = this.L("CompleteTransaction");
                if (allSettingsByTenantId.PaymentGatewaySettings.GatewaySettings.Length <= 3)
                {
                    throw new Exception("PaymentGatewayError_PayEezySettingsMissing");
                }
                PayEezyJsonObject payEezyJsonObject = JsonConvert.DeserializeObject <PayEezyJsonObject>(allSettingsByTenantId.PaymentGatewaySettings.GatewaySettings);
                payNowDto.x_login           = payEezyJsonObject.PayEezy_x_login;
                payNowDto.x_transaction_key = payEezyJsonObject.PayEezy_x_transaction_key;
                PayNowDto payNowDto3          = payNowDto;
                bool?     payEezyXTestRequest = payEezyJsonObject.PayEezy_x_test_request;
                payNowDto3.x_test_request = bool.Parse(payEezyXTestRequest.ToString());
                PayNowDto payNowDto4 = payNowDto;
                payEezyXTestRequest         = payEezyJsonObject.PayEezy_x_email_customer;
                payNowDto4.x_email_customer = bool.Parse(payEezyXTestRequest.ToString());
                payNowDto.x_gateway_id      = payEezyJsonObject.PayEezy_x_gateway_id;
                PayNowDto payNowDto5          = payNowDto;
                string    payEezyXDescription = payEezyJsonObject.PayEezy_x_description;
                str1 = (formFields["Description"] == null || formFields["Description"] != null && formFields["Description"].ToString().Length > 0 ? string.Concat(" ", formFields["Description"].ToString()) : "");
                payNowDto5.x_description = string.Concat(payEezyXDescription, str1);
                payNowDto.x_amount       = num2;
                payNowDto.x_customer_ip  = PayController.GetIPAddress(this.Request);
                Random    random = new Random();
                PayNowDto str5   = payNowDto;
                int       num4   = random.Next(0, 1000);
                str5.x_fp_sequence = num4.ToString();
                TimeSpan utcNow = DateTime.UtcNow - new DateTime(1970, 1, 1);
                payNowDto.x_fp_timestamp = ((int)utcNow.TotalSeconds).ToString();
                payNowDto.x_fp_hash      = PayController.GeneratePayeezyHash(payNowDto.x_transaction_key, payNowDto.x_login, payNowDto.x_amount, payNowDto.x_fp_sequence, payNowDto.x_fp_timestamp, "USD");
                if (!payNowDto.x_test_request)
                {
                    payNowDto.PostToUrl = "https://checkout.globalgatewaye4.firstdata.com/payment";
                }
                else
                {
                    payNowDto.PostToUrl = "https://demo.globalgatewaye4.firstdata.com/payment";
                }
                allSettingsByTenantId = null;
                invoice = null;
                str4    = null;
            }
            catch (Exception)
            {
                payNowDto = new PayNowDto();
                ((dynamic)this.ViewBag).Error_InvalidParameters = true;
            }
            return(this.View(payNowDto));
        }