Esempio n. 1
0
 private void button_AddBeverage_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView_Order.Items.Count == 0)
         {
             BillInforDAO.Instance.CreateBill();
             textBox_ExcessCash.Text = "0";
         }
         listView_Order.Items.Clear();
         int      IDBill         = BillInforDAO.Instance.getIDBillInfor();
         int      BeverID        = MenuDAO.Instance.GetIdFromSelectedTextbox(textBox_BeverageSelected.Text);
         bool     CheckBeverages = orderDa.CheckExistBeverage(BeverID, IDBill);
         int      Amount         = (int)numericUpDown_Amount.Value;
         ICommand insertOrder    = new InsertOrderCommand(orderDa, BeverID, IDBill, Amount);
         if (CheckBeverages)
         {
             orderDa.UpdateAmountOrder(Amount, BeverID, IDBill);
         }
         else
         {
             insertOrder.Execute();
             /*orderDa.InsertOrder(IDBill, BeverID, Amount);*/
         }
         LoadOrderList();
     }
     catch
     {
         MessageBox.Show("Hãy chọn đồ uống cần thêm");
     }
 }
Esempio n. 2
0
        public static int InsertOrder(Order order)
        {
            using (ObjectConnection objectConnection = new ObjectConnection())
            {
                using (InsertOrderCommand objectCommand = new InsertOrderCommand(objectConnection))
                {
                    objectCommand.OrderId          = order.OrderId;
                    objectCommand.OrderEntryDate   = order.OrderEntryDate;
                    objectCommand.OrderFulfillDate = order.OrderFulfillDate;
                    objectCommand.OrderStatusId    = order.OrderStatusId;
                    objectCommand.PersonId         = order.PersonId;

                    objectConnection.Open();
                    objectCommand.ExecuteNonQuery();

                    return(objectCommand.ReturnValue);
                }
            }
        }
Esempio n. 3
0
 public static Order ToEntity(this InsertOrderCommand model)
 {
     return(model.MapTo <InsertOrderCommand, Order>());
 }
Esempio n. 4
0
        public async Task <ActionResult <int> > CheckoutOrder([FromBody] InsertOrderCommand command)
        {
            var result = await _mediator.Send(command);

            return(Ok(result));
        }