Exemple #1
0
        public void TestOrderNumAssignment()
        {
            var testOrder = new Order();
            testOrder.Name = "Smith";
            testOrder.State = "OH";
            testOrder.TaxRate = 0.10M;
            testOrder.ProductType = "Carpet";
            testOrder.Area = 5M;
            testOrder.CostPerSquareFoot = 2M;
            testOrder.LaborCostPerSquareFoot = 1M;
            testOrder.MaterialCost = 4M;
            testOrder.LaborCost = 10M;
            testOrder.Tax = 10M;
            testOrder.Total = 10M;

            AddOrder p = new AddOrder();
            var list = p.GetTodaysOrders();
            int n = p.GetNextOrderNumber(list);
            Assert.IsTrue(n == 1);
        }
 private void AddUserToTask(AddOrder<IUser, int> order)
 {
     this.context.AddTaskToUser(order.Model, order.WithIn);
 }
 private void AddTaskRecord(AddOrder<ITaskRecord, int> order)
 {
     this.context.AddTaskRecord(order.Model, order.WithIn);
 }
 private void AddTaskComment(AddOrder<ITaskComment, int> order)
 {
     this.context.AddTaskComment(order.Model, order.WithIn);
 }
 /// <summary>
 /// Method to Place an Order
 /// </summary>
 /// <param name="order">order data</param>
 void IWaiterService.PlaceOrder(AddOrder order)
 {
     try
     {
         this.waiterBL.PlaceOrder(order);
     }
     catch (Exception ex)
     {
         ServiceFaultDetails serviceException = new ServiceFaultDetails();
         serviceException.ErrorMessage = ex.Message;
         serviceException.Result = false;
         throw new FaultException<ServiceFaultDetails>(serviceException);
     }
 }
        /// <summary>
        /// Click event to handle Addition of Order
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">event data</param>
        private void BtnAddOrder_Click(object sender, EventArgs e)
        {
            try
            {
                itemCount = 0;
                AddOrder order = new AddOrder();
                List<FoodItem> lstFoodItem = new List<FoodItem>();
                string tableNumber = Convert.ToString(comboBox1.SelectedItem);
                if (!string.IsNullOrEmpty(tableNumber) &&
                    (listView2.Items.Count > 0) )
                {
                    order.TableNumber = tableNumber;
                    int i = 0;
                    foreach (ListViewItem lvItem in listView2.Items)
                    {
                        string item = listView2.Items[i].SubItems[0].Text.ToString();
                        double price = double.Parse(listView2.Items[i].SubItems[1].Text, CultureInfo.InvariantCulture);
                        int quantity = int.Parse(listView2.Items[i].SubItems[2].Text);
                        double subTotal;
                        double.TryParse(listView2.Items[i].SubItems[2].Text, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture, out subTotal);

                        lstFoodItem.Add(new FoodItem() { DishName = item, ItemQty = quantity });
                        i++;
                    }

                    if (lstFoodItem.Count > 0)
                    {
                        order.Items = lstFoodItem;
                        waiterClient.PlaceOrder(order);
                        listView2.Items.Clear();
                        lblTotal.Text = "";
                        total = 0;
                        MessageBox.Show("Order Placed Successfully");
                    }
                }
                else
                {
                    MessageBox.Show("Order list is Empty. Place an Order");
                }
            }
            catch (FaultException<RestaurantService.Contracts.ServiceFaultDetails> ex)
            {
                MessageBox.Show("Error:" + ex.Detail.ErrorMessage);
            }
            catch (CommunicationException ex)
            {
                MessageBox.Show("Error:" + ex.Message);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("Error:" + ex.Message);
            }
        }