public async Task <ActionResult <DeliveryPayment> > DeliveryPayment(int affiliateId, int customerId)
        {
            DeliveryPayment returnModel = new DeliveryPayment(Data.Affiliates.Single(x => x.AffiliateId == affiliateId), customerId);

            DeliveryPayment deliveryPayment = await Data.GetDeliveryPayment(affiliateId, customerId).ConfigureAwait(false);

            if (deliveryPayment != null)
            {
                returnModel.PaymentTypeId         = deliveryPayment.PaymentTypeId;
                returnModel.DeliveryTypeId        = deliveryPayment.DeliveryTypeId;
                returnModel.Bic                   = deliveryPayment.Bic;
                returnModel.Iban                  = deliveryPayment.Iban;
                returnModel.AccountOwner          = deliveryPayment.AccountOwner;
                returnModel.CustomerGroupId       = deliveryPayment.CustomerGroupId;
                returnModel.CustomerGroupName     = deliveryPayment.CustomerGroupName;
                returnModel.CustomerGroupDiscount = deliveryPayment.CustomerGroupDiscount;
                deliveryPayment                   = null;

                returnModel.InvoiceItems.Items.AddRange(await Data.GetInvoiceItems(affiliateId, customerId).ConfigureAwait(false));
            }

            returnModel.BillingAddress = await Data.GetBillingAddress(affiliateId, customerId).ConfigureAwait(false);

            returnModel.DeliveryAddress = await Data.GetDeliveryAddress(affiliateId, customerId).ConfigureAwait(false);

            if (string.IsNullOrEmpty(returnModel.DeliveryAddress.Country))
            {
                returnModel.DeliveryAddress.Country = returnModel.BillingAddress.Country;
            }
            returnModel.DeliveryAddresses.AddRange(await Data.GetDeliveryAddresses(customerId).ConfigureAwait(false));

            returnModel.PaymentTypes.AddRange(Data.GetPaymentTypes(affiliateId));

            if (returnModel.PaymentTypeId.HasValue)
            {
                returnModel.DeliveryTypes.AddRange(Data.GetDeliveryTypes(affiliateId, returnModel.PaymentTypeId.Value));
            }

            returnModel.DeliveryPaymentButtons.AddRange(await Data.GetDeliveryPaymentButtons(affiliateId).ConfigureAwait(false));

            ViewData["Title"] = string.Concat(returnModel.BillingAddress.FullName, " (", returnModel.Affiliate.Key, ")");
            ViewData["WebServiceHostName"] = Data.WebServiceHostName;
            SetAffiliateColours(0.25);

            return(View(returnModel));
        }
Beispiel #2
0
        public async Task <DeliveryPayment> GetDeliveryPayment(int affiliateId, int customerId)
        {
            if (affiliateId < 1 ||
                customerId < 1)
            {
                return(null);
            }
            else
            {
                string json = await base.GetJsonAsync("/webapplication/servicecenter/getinvoice", new Dictionary <string, object>() { { "affiliateId", affiliateId }, { "customerid", customerId } }).ConfigureAwait(false);

                DeliveryPayment deliveryPayment = JsonConvert.DeserializeObject <DeliveryPayment>(json);

                if (deliveryPayment.CustomerGroupId != 0)
                {
                    deliveryPayment.CustomerGroupName = CustomerGroups.Single(x => x.CustomerGroupId == deliveryPayment.CustomerGroupId).CustomerGroupName;
                }

                return(deliveryPayment);
            }
        }