public ProjectsUserControl(Order order)
 {
     InitializeComponent();
     _projectsUserControlVM = new ProjectsUserControlVM(order);
     DataContext = _projectsUserControlVM;
     ProjectsDataGrid.DataContext = null;
     ProjectsDataGrid.Visibility = Visibility.Hidden;
 }
 public Order addOrder(Order order)
 {
     /// <summary>
     /// dodaje zamowienie
     /// </summary>
     /// <param name="order"></param>
     /// <returns>zwraca id zamowienia konkretnego pojazdu przez konkretnego klienta</returns>
     throw new NotImplementedException();
 }
 public int CreateOrder(List<OrderDetail> OrderDetails, string CustomerId, decimal Freight, int ShipVia, string ShipName, string ShipAddress, string ShipCity,
     string ShipRegion, string ShipPostalCode, string ShipCountry)
 {
     var order = new Order()
                     {
                         CustomerId = CustomerId,
                         Freight = Freight,
                         OrderDate = DateTime.Today,
                         RequiredDate = DateTime.Today.AddDays(7.0),
                         ShipAddress = ShipAddress,
                         ShipCity = ShipCity,
                         ShipCountry = ShipCountry,
                         ShipPostalCode = ShipPostalCode,
                         ShipRegion = ShipRegion,
                         ShipName = ShipName,
                         ShipVia = ShipVia,
                         OrderDetails = OrderDetails
                     };
     order = _context.Orders.Add(order);
     return order.OrderId;
 }
Example #4
0
 public void CanSaveOrderWithItems()
 {
     int olo;
     using(var session=FactoryProvider.Factory.OpenSession())
         using(var transaction=session.BeginTransaction())
         {
             var order = new Order();
             order.EmissionDay = DateTime.Now;
             order.AddItem(new OrderItem{Product = "oo", Order = order, Price = 100});
             order.AddItem(new OrderItem{Product = "o22", Order = order, Price = 140});
             session.Save(order);
             transaction.Commit();
             olo = order.Id;
         }
     using(var session=FactoryProvider.Factory.OpenSession())
         using(var transaction=session.BeginTransaction())
         {
             var order = session.Get<Order>(olo);
             Assert.AreEqual(2, order.Items.Count());
         }
 }
Example #5
0
        protected void btnPlaceOrder_Click(object sender, EventArgs e)
        {
            var order = new Order();

            //Get method of shipping and freightCost
            order.ShipVia = Convert.ToInt32(ddlShipVia.SelectedValue);
            order.ShipName = txtShipName.Text;
            order.ShipAddress = txtShipAddress.Text;
            order.ShipCity = txtShipCity.Text;
            order.ShipRegion = txtShipRegion.Text;
            order.ShipPostalCode = txtShipPostalCode.Text;
            order.ShipCountry = txtShipCountry.Text;
            order.OrderDetails = _cart.OrderDetails;
            order.CustomerId = _customer.CustomerId;
            order.OrderDate = DateTime.Now;
            order.RequiredDate = DateTime.Now.AddDays(7);
            order.Freight = _shipperRepository.GetShipperByShipperId(Convert.ToInt32(ddlShipVia.SelectedValue)).GetShippingCost(_cart.SubTotal);
            //TODO: Throws an error if we don't set the date. Try to set it to null or something.
            order.ShippedDate = DateTime.Now.AddDays(3);
            order.EmployeeId = 1;

            //Get form of payment
            //If old card is null or if the number, month or year were changed then take what was on the form.
            if (_creditCard.Number.Length <= 4)
            {
                _creditCard.Number = txtCreditCardNumber.Text;
                _creditCard.Expiry = new DateTime(Convert.ToInt32(ddlExpiryYear.SelectedValue),
                    Convert.ToInt32(ddlExpiryMonth.SelectedValue), 1);
            }
            else
            {
                if (txtCreditCardNumber.Text.Substring(txtCreditCardNumber.Text.Length - 4) !=
                _creditCard.Number.Substring(_creditCard.Number.Length - 4))
                {
                    _creditCard.Number = txtCreditCardNumber.Text;
                }
                if (ddlExpiryMonth.SelectedValue != _creditCard.ExpiryMonth.ToString("00") ||
                ddlExpiryYear.SelectedValue != _creditCard.ExpiryYear.ToString("0000"))
                {
                    _creditCard.Expiry = new DateTime(Convert.ToInt32(ddlExpiryYear.SelectedValue),
                        Convert.ToInt32(ddlExpiryMonth.SelectedValue), 1);
                }
            }
            //Authorize payment through our bank or Authorize.net or someone.
            if (!_creditCard.IsValid())
            {
                lblErrorMessage.Text = "That card is not valid.  Please enter a valid card.";
                return;
            }
            var approvalCode = _creditCard.ChargeCard(order.Total);

            if (chkStoreCCNumber.Checked)
                _creditCard.SaveCardForUser();

            var shipment = new Shipment()
                {
                    ShipmentDate = DateTime.Today.AddDays(1),
                    ShipperId = order.ShipVia,
                    TrackingNumber = _shipperRepository.GetNextTrackingNumber(_shipperRepository.GetShipperByShipperId(order.ShipVia)),
                };
            //TODO: Uncommenting this line causes EF to throw exception when creating the order.
            //order.Shipment = shipment;

            //Create the order itself.
            int orderId = _orderRepository.CreateOrder(order);
            Session["OrderId"] = orderId;
            Session["Cart"] = null;

            //Create the payment record.
            _orderRepository.CreateOrderPayment(orderId, order.Total, _creditCard.Number, _creditCard.Expiry, approvalCode);

            //Show success page
            Response.Redirect("Receipt.aspx");
        }
 public void UpdateOrder(Order Order)
 {
     _context.Entry(Order).State = System.Data.EntityState.Modified;
     _context.SaveChanges();
 }
 public int CreateOrder(Order Order)
 {
     Order = _context.Orders.Add(Order);
     _context.SaveChanges();
     return Order.OrderId;
 }