public void PopulateAddresses(int customerId)
    {
        BillingAddresses.Items.Clear();

        using (SqlConnection connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            using (SqlCommand command = new SqlCommand("select AddressID, Address1 + ' ' + City + ', ' + State + ', ' + Zip + ' ' + Country [DisplayValue] from Address where CustomerID = @customerId and Deleted = 0", connection))
            {
                command.Parameters.AddRange(new[] {
                    new SqlParameter("@customerId", customerId),
                });

                SqlDataAdapter      adapter = new SqlDataAdapter(command);
                System.Data.DataSet dataSet = new System.Data.DataSet();
                adapter.Fill(dataSet);

                BillingAddresses.DataSource     = dataSet;
                BillingAddresses.DataTextField  = "DisplayValue";
                BillingAddresses.DataValueField = "AddressID";
                BillingAddresses.DataBind();
            }
        }
    }
Beispiel #2
0
        public async Task <IActionResult> Import([FromBody] OrderXml model)
        {
            foreach (var orderItem in model.Orders)
            {
                var order = new Orders
                {
                    OxId          = orderItem.OxId,
                    OrderDatetime = orderItem.OrderDatetime,
                };
                db.Add(order);
                foreach (var billingAddressItem in orderItem.BillingAddresses)
                {
                    var billingAddress = new BillingAddresses
                    {
                        OrderOx    = order,
                        Email      = billingAddressItem.Email,
                        Fullname   = billingAddressItem.Fullname,
                        Country    = billingAddressItem.Country.Code,
                        City       = billingAddressItem.City,
                        Street     = billingAddressItem.Street,
                        HomeNumber = billingAddressItem.HomeNumber,
                        Zip        = billingAddressItem.Zip,
                    };
                    db.Add(billingAddress);
                }
            }

            await db.SaveChangesAsync();

            return(Ok());
        }
Beispiel #3
0
 public static BillingAdressViewModel ToViewModel(this BillingAddresses billingAddress)
 {
     return(new BillingAdressViewModel()
     {
         Email = billingAddress.Email,
         Fullname = billingAddress.Fullname,
         Street = billingAddress.Street,
         HomeNumber = billingAddress.HomeNumber,
         City = billingAddress.City,
         Country = billingAddress.Country,
         Zip = billingAddress.Zip
     });
 }
 private void FillAddressCollection(List <Address> addresses, QIQOAddressType address_type)
 {
     if (address_type == QIQOAddressType.Billing)
     {
         BillingAddresses.Clear();
         foreach (var addr in addresses)
         {
             BillingAddresses.Add(new AddressWrapper(addr));
         }
     }
     else
     {
         ShippingAddresses.Clear();
         foreach (var addr in addresses)
         {
             ShippingAddresses.Add(new AddressWrapper(addr));
         }
     }
 }
    public void BindPage(Int64 paymentProfileId)
    {
        DisableButtonOnClick(ButtonSave);

        ErrorMessage.Text     = string.Empty;
        TextCardSecurity.Text = string.Empty;
        TextCreditCard.Text   = string.Empty;

        AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current;
        int customerId = adnsfCustomer.CustomerID;

        PanelError.Visible = false;
        PopulateExpirationDates();
        PopulateAddresses(customerId);

        this.PaymentProfileId = 0;         // initially zero

        if (paymentProfileId <= 0)
        {
            return;
        }

        Int64 profileId = DataUtility.GetProfileId(customerId);

        if (profileId <= 0)
        {
            return;
        }

        var profileMgr     = new ProfileManager(customerId, adnsfCustomer.EMail, profileId);
        var paymentProfile = profileMgr.GetPaymentProfile(paymentProfileId);

        if (paymentProfile == null)
        {
            return;
        }

        this.PaymentProfileId = paymentProfileId;

        var ccPayment          = (GatewayAuthorizeNet.AuthorizeNetApi.CreditCardMaskedType)paymentProfile.payment.Item;
        var dataPaymentProfile = DataUtility.GetPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId);

        TextCreditCard.Text   = ccPayment.cardNumber;
        TextCardSecurity.Text = string.Empty;

        ExpirationMonth.ClearSelection();
        var foundItem = ExpirationMonth.Items.FindByValue(dataPaymentProfile.ExpirationMonth);

        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        ExpirationYear.ClearSelection();
        foundItem = ExpirationYear.Items.FindByValue(dataPaymentProfile.ExpirationYear);
        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        var address = DataUtility.GetPaymentProfile(customerId, this.PaymentProfileId);

        if (address != null)
        {
            BillingAddresses.ClearSelection();
            BillingAddresses.Items.FindByValue(address.AddressId.ToString()).Selected = true;
        }
    }
Beispiel #6
0
        public IActionResult SubmitOrder(BillingAddresses newBilling, ShippingAddresses newShipping, PaymentMethods newPayment, string month, string year)
        {
            var    user       = HttpContext.Session.GetInt32("user");
            var    cart       = _context.Cart.Where(x => x.UsersId == (int)user).Include(y => y.Product).ToList();
            string expiration = month + "/" + year;

            if (ModelState.IsValid)
            {
                _context.BillingAddresses.Add(newBilling);
                _context.ShippingAddresses.Add(newShipping);
                _context.SaveChanges();
                PaymentMethods newPay = new PaymentMethods()
                {
                    UsersId            = (int)user,
                    BillingAddressesId = newBilling.id,
                    card_type          = newPayment.card_type,
                    card_name          = newPayment.card_name,
                    card_num           = newPayment.card_num,
                    card_ccv           = newPayment.card_ccv,
                    card_exp           = expiration,
                    nickname           = newPayment.nickname,
                };
                _context.PaymentMethods.Add(newPay);
                _context.SaveChanges();
                Orders newOrder = new Orders()
                {
                    UsersId             = (int)user,
                    BillingAddressesId  = newBilling.id,
                    ShippingAddressesId = newShipping.id,
                    PaymentMethodsId    = newPay.id,
                    order_status        = "Processing"
                };
                _context.Orders.Add(newOrder);
                _context.SaveChanges();
                foreach (var item in cart)
                {
                    Inventory      updateInventory = _context.Inventory.FirstOrDefault(x => x.ProductsId == item.ProductsId);
                    Order_Products newItem         = new Order_Products()
                    {
                        OrdersId   = newOrder.id,
                        ProductsId = item.ProductsId,
                        quantity   = item.quantity,
                        cost       = item.cost
                    };
                    updateInventory.quantity_new  -= item.quantity;
                    updateInventory.quantity_sold += item.quantity;
                    _context.Order_Products.Add(newItem);
                    _context.Cart.Remove(item);
                    _context.SaveChanges();
                }
                return(RedirectToAction("OrderView"));
            }

            ViewBag.cart = _context.Cart.Where(x => x.UsersId == HttpContext.Session.GetInt32("user"))
                           .Include(y => y.Product).ThenInclude(z => z.Prices)
                           .Include(y => y.Product).ThenInclude(z => z.product_img).ToList();
            ViewBag.cost = 0;
            foreach (var item in ViewBag.cart)
            {
                ViewBag.cost += item.cost;
            }
            return(View("Checkout"));
        }