Beispiel #1
0
        public static void WaiterMenu()
        {
            Boolean continuar = true;

            while (continuar)
            {
                Console.WriteLine("Ingrese el numero que antescede la opcion que desea \n\n1.Elegir mesa y ordernar" +
                                  "\n2.Cerrar Sesion");
                int option = Convert.ToInt32(Console.ReadLine());
                switch (option)
                {
                case 1:
                    List <Table> tables    = Tablelogic.GetAvailableTables();
                    string       tableList = "";
                    foreach (var i in tables)
                    {
                        tableList += i.ID + ". Cantidad de personas: " + i.People + "\n";
                    }
                    Console.WriteLine("****MESAS DISPONIBLES**** \n\n" + tableList);
                    Console.WriteLine("Ingrese el id de la mesa en la que desea ordear");
                    int table_id = Convert.ToInt16(Console.ReadLine());
                    Tablelogic.PickTable(table_id);
                    Boolean        continuarOrdenando = true;
                    List <Product> products           = Produclogic.GetProducts();
                    string         productList        = "";
                    foreach (var i in products)
                    {
                        productList += i.ID + ". " + i.Name + ". " + i.Description + ". Costo: " + i.Cost + "\n";
                    }
                    Console.WriteLine("****LISTA DE PRODUCTOS**** \n\n" + productList);
                    while (continuarOrdenando)
                    {
                        Console.WriteLine("Ingrese el id del producto para ordenar. Pulsa 0 a para salir.");
                        int optionOrder = Convert.ToInt32(Console.ReadLine());
                        if (optionOrder == 0)
                        {
                            continuarOrdenando = false;
                        }
                        else
                        {
                            Order_Product orden = Orderlogic.CreateOrder(table_id, optionOrder, Produclogic.SearchByID(optionOrder).Cost);
                            Console.WriteLine("Se realizo la orden " + orden.ID);
                        }
                    }
                    break;

                case 2:
                    continuar = false;
                    break;
                }
            }
        }
Beispiel #2
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     if (comboBoxCar.SelectedValue == null)
     {
         MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         _logicOrder.CreateOrder(new OrderBindingModel
         {
             CustomerId = Convert.ToInt32(comboBoxClient.SelectedValue),
             CarId      = Convert.ToInt32(comboBoxCar.SelectedValue),
             EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
             Date       = DateTime.Now
         });
         MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        // Zdarzenie wysyłania zamówienia. Występuje formatka do wprowadzania adresu. Utworzenie zamówienia w bazie danych plus wysłanie maila.
        private void uiBtnSendOrder_Click(object sender, EventArgs e)
        {
            string message;

            if (!_orderLogic.Validate(out message, uiTxtEmail.Text, uiClbShopingCard.Items.Count))
            {
                MessageBox.Show(message, Resources.Attention, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            AddressObject addressObject = _orderLogic.CreateAddress();

            if (addressObject == null)
            {
                MessageBox.Show(Resources.NotSetEmailAddress, Resources.Attention, MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            List <OrderProductObject> orderProductObjects = new List <OrderProductObject>();

            foreach (object obj in uiClbShopingCard.Items)
            {
                orderProductObjects.Add(new OrderProductObject(obj.ToString()));
            }

            OrderObject orderObject = CreateOrderObject();

            _orderLogic.CreateOrder(orderObject, addressObject, orderProductObjects);
            Close();
        }
 private void ButtonSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxCount.Text))
     {
         MessageBox.Show("Заполните поле Количество", "Ошибка",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (comboBoxProduct.SelectedValue == null)
     {
         MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     try
     {
         _logicO.CreateOrder(new CreateOrderBindingModel
         {
             ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue),
             Count     = Convert.ToInt32(textBoxCount.Text),
             Sum       = Convert.ToDecimal(textBoxSum.Text)
         });
         MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Beispiel #5
0
        public void AnOrderIsCreated()
        {
            OrderLogic logic = new OrderLogic();

            logic.CreateOrder(1, 1, 2500);
            Order lastOrder = logic.SearchOrderById(1);

            Assert.IsNotNull(lastOrder);
        }
Beispiel #6
0
        public void ValidateOrderLinePricesToPreventInsecureDirectObjectReference()
        {
            Product p = productDB.Get("productID", 1.ToString());
            //Price on OrderLine is incorrect and should be caught
            OrderLine        ol         = new OrderLine(1, 100, p);
            List <OrderLine> orderLines = new List <OrderLine>();

            orderLines.Add(ol);

            Order o = orderLogic.CreateOrder("Rune", "Andersen", "Istedgade 10", 9000, "Aalborg", "*****@*****.**", 12341234, orderLines);


            Assert.AreEqual(o.ErrorMessage, "");
        }
Beispiel #7
0
        public ActionResult <Order> SubmitOrder([FromBody] RawOrder obj)
        {
            Order newOrder;

            if (!ModelState.IsValid)
            {
                return(StatusCode(400, "Failed to create models"));
            }
            else
            {
                newOrder = orderLogic.CreateOrder(obj);
            }

            return(newOrder);
        }
Beispiel #8
0
        public void OnlyNotPaidOrdersCanBeListedToBePaid()
        {
            OrderLogic logic = new OrderLogic();

            logic.CreateOrder(1, 1, 2500);
            List <Order> orders = logic.GetOrdersToPay(1);

            Assert.IsNotNull(orders);
            foreach (var i in orders)
            {
                logic.PayOrder(i);
            }
            orders.Clear();
            orders = logic.GetOrdersToPay(1);
            Assert.AreEqual(orders.Count, 0);
        }
Beispiel #9
0
        public JsonResult CreateOrder(CreateOrderInput input)
        {
            bool isSuccess = OrderLogic.CreateOrder(input) > 0;

            return(Json(isSuccess, JsonRequestBehavior.AllowGet));
        }
        public void Test_CreateOrder()
        {
            var options = new DbContextOptionsBuilder <OrderContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb21")
                          .Options;
            var options1 = new DbContextOptionsBuilder <StoreContext>()
                           .UseInMemoryDatabase(databaseName: "TestDb21")
                           .Options;
            var options2 = new DbContextOptionsBuilder <CustomerContext>()
                           .UseInMemoryDatabase(databaseName: "TestDb21")
                           .Options;

            using (var context = new OrderContext(options))
            {
                using (var context1 = new StoreContext(options1))
                {
                    using (var context2 = new CustomerContext(options2))
                    {
                        context.Database.EnsureDeleted();
                        context.Database.EnsureCreated();
                        context1.Database.EnsureDeleted();
                        context1.Database.EnsureCreated();
                        context2.Database.EnsureDeleted();
                        context2.Database.EnsureCreated();

                        OrderRepository    orderRepo = new OrderRepository(context);
                        StoreRepository    storeRepo = new StoreRepository(context1);
                        CustomerRepository custRepo  = new CustomerRepository(context2);
                        OrderLogic         ol        = new OrderLogic(orderRepo, storeRepo, custRepo);

                        AStore          store       = new AStore();
                        Customer        newCust     = new Customer();
                        ItemType        item        = new ItemType("toppings");
                        APizzaComponent testCrust   = new APizzaComponent("testcrust", item);
                        APizzaComponent testTopping = new APizzaComponent("testtopping", item);
                        APizzaComponent testSize    = new APizzaComponent("testsize", item);
                        Crust           tempCrust   = new Crust(store, 0, 1, testCrust);
                        Topping         tempTopping = new Topping(store, 0, 1, testTopping);
                        Size            tempSize    = new Size(store, 0, 1, testSize);

                        context1.Add <AStore>(store);
                        context2.Add <Customer>(newCust);
                        context1.Add <ItemType>(item);
                        context1.Add <APizzaComponent>(testCrust);
                        context1.Add <APizzaComponent>(testTopping);
                        context1.Add <APizzaComponent>(testSize);
                        context1.Add <Crust>(tempCrust);
                        context1.Add <Topping>(tempTopping);
                        context1.Add <Size>(tempSize);
                        context.SaveChanges();
                        context1.SaveChanges();
                        context2.SaveChanges();

                        RawPizza rawTest = new RawPizza();
                        rawTest.Name     = "Test Pizza";
                        rawTest.Price    = 0;
                        rawTest.Crust    = "testcrust";
                        rawTest.Size     = "testsize";
                        rawTest.Toppings = new List <string>();
                        rawTest.Toppings.Add("testtopping");

                        RawOrder newOrder = new RawOrder();
                        newOrder.PizzaList  = new List <RawPizza>();
                        newOrder.StoreID    = store.StoreID;
                        newOrder.CustomerID = newCust.CustomerID;
                        newOrder.Total      = 0;
                        newOrder.PizzaList.Add(rawTest);

                        Order createOrder = ol.CreateOrder(newOrder);
                        Assert.NotNull(createOrder);
                    }
                }
            }
        }