private void SendComfirmationMail(SalesOrderHeader salesOrderHeader, Customer customer)
        {
            try
            {
                var subject = "Thank you for ordering form FlyCycles";
                var body = $"We have recived your order with the order ID {salesOrderHeader.SalesOrderNumber}.\r\n" +
                           $"Best regards\r\n" +
                           $"FlyCycles";

                WebShopController.SendMail(WebShopController.SuportMail,
                    new MailAddress(customer.EmailAddress, $"{customer.FirstName} {customer.LastName}"), subject, body);
            }
            catch (Exception ex)
            {
                // TODO: Logg order confirm mail error.

                panelMail.Visible = false;
                panelMailError.Visible = true;
            }
        }
        protected void btnConfirmOrder_Click(object sender, EventArgs e)
        {
            try
            {
                var shopingCart = (ShopingCart)Session[WebShopController.SessionKeyShopingCart];

                using (var db = new AvensiaWebshopEntities())
                {
                    var customer = new Customer()
                    {
                        NameStyle = false,
                        FirstName = txtFNamn.Text.Trim(),
                        LastName = txtENamn.Text.Trim(),
                        EmailAddress = txtEPost.Text.Trim(),
                        PasswordHash = "",
                        PasswordSalt = "",
                        rowguid = Guid.NewGuid(),
                        ModifiedDate = DateTime.Now

                    };
                    db.Customer.Add(customer);

                    var address = new Address()
                    {
                        AddressLine1 = txtAdress.Text.Trim(),
                        AddressLine2 = txtCoAdress.Text.Trim(),
                        City = txtOrt.Text.Trim(),
                        StateProvince = "",
                        CountryRegion = "",
                        PostalCode = txtPostNr.Text.Trim(),
                        rowguid = Guid.NewGuid(),
                        ModifiedDate = DateTime.Now
                    };
                    db.Address.Add(address);

                    db.SaveChanges();

                    var salesOrderHeader = new SalesOrderHeader()
                    {
                        OrderDate = DateTime.Today,
                        DueDate = DateTime.Today.AddDays(14),
                        SalesOrderNumber = "Number",
                        CustomerID = customer.CustomerID,
                        ShipToAddressID = address.AddressID,
                        ShipMethod = rblDeliveryOptions.SelectedItem.Text,
                        TaxAmt = shopingCart.SumTotal * (decimal)0.2,
                        ModifiedDate = DateTime.Now,
                        rowguid = Guid.NewGuid(),
                        Freight = GetFreightPrice()
                    };
                    db.SalesOrderHeader.Add(salesOrderHeader);

                    db.SaveChanges();

                    foreach (var cartItem in shopingCart.CartItems)
                    {
                        db.SalesOrderDetail.Add(new SalesOrderDetail()
                        {
                            SalesOrderID = salesOrderHeader.SalesOrderID,
                            OrderQty = cartItem.Quantity,
                            ProductID = cartItem.ProductID,
                            UnitPrice = cartItem.Price * (decimal)0.8,
                            UnitPriceDiscount = (decimal)0,
                            rowguid = Guid.NewGuid(),
                            ModifiedDate = DateTime.Now
                        });

                        db.SaveChanges();
                    }


                    Session["LastOrderID"] = salesOrderHeader.SalesOrderID;
                }
            }
            catch (Exception ex)
            {
                Session["LastOrderID"] = null;

                throw;
            }
            Session[WebShopController.SessionKeyShopingCart] = new ShopingCart();
            Response.Redirect("/Bekraftelse.aspx");
        }