Пример #1
0
        public void TestDeleteOrderProducts()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                OrderBinding model1 = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                model1.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1
                });
                logicP.Create(new ProductBinding());
                logicO.Create(model1);
                logicO.Delete(model1);
                OrderBinding model2 = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1
                });
                logicO.Create(model2);

                List <OrderView> list = logicO.Read(null);

                Assert.Single(list[0].OrderProducts);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #2
0
        public void TestDeleteSingle()
        {
            OrderLogic logic = new OrderLogic();

            try
            {
                OrderBinding model1 = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                OrderBinding model2 = new OrderBinding {
                    Id = 2, OrderProducts = new List <OrderProductBinding>()
                };
                logic.Create(model1);
                logic.Create(model2);
                logic.Delete(model1);

                List <OrderView> list = logic.Read(null);

                Assert.Single(list);
                Assert.Equal(2, list[0].Id);
            }
            finally
            {
                logic.Delete(null);
            }
        }
Пример #3
0
        public void TestMethodSaveCreatedOrder()
        {
            string          message = "";
            OrderLogic      logicO  = new OrderLogic();
            ProductLogic    logicP  = new ProductLogic();
            OrderPageDriver driver  = new OrderPageDriver(new UiContext(logicO, logicP), null);

            driver.ShowInfoMessage = (msg) => { message = msg; };

            try
            {
                logicP.Create(new ProductBinding {
                    Price = 10
                });
                driver.MoveToOrderProductPage = (context, order, orderProduct) => order.OrderProducts.Add(new OrderProductView {
                    ProductId = 1
                });
                driver.AddOrderProduct();
                driver.AddOrderProduct();
                driver.AddOrderProduct();

                bool             result = driver.SaveOrder();
                List <OrderView> list   = logicO.Read(null);

                Assert.True(result);
                Assert.Single(list);
                Assert.Single(list[0].OrderProducts);
                Assert.Equal("Order was created", message);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #4
0
        public void TestMethodDelete()
        {
            string           message    = "";
            OrderLogic       orderLogic = new OrderLogic();
            OrdersPageDriver driver     = new OrdersPageDriver(new UiContext(new OrderLogic(), new ProductLogic()));

            driver.ShowInfoMessage = (msg) => { message = msg; };

            try
            {
                orderLogic.Create(new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                });
                orderLogic.Create(new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                });
                orderLogic.Create(new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                });
                driver.SelectedOrder = () => orderLogic.Read(null)[1];

                driver.DeleteOrder();
                List <OrderView> list = driver.GetAllOrders();

                Assert.Equal(2, list.Count);
                Assert.Equal(1, list[0].Id);
                Assert.Equal(3, list[1].Id);
                Assert.Equal("Order №2 was deleted", message);
            }
            finally
            {
                orderLogic.Delete(null);
            }
        }
Пример #5
0
        public void TestOrderProductPrice()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                ProductBinding product = new ProductBinding {
                    Name = "Test", Price = 20
                };
                OrderBinding order = new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                };
                order.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 2
                });
                logicP.Create(product);
                logicO.Create(order);

                List <OrderView> list = logicO.Read(null);

                Assert.Equal(20, list[0].OrderProducts[0].Price);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #6
0
        public void TestCreateWithOrderProducts()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                OrderBinding model = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                model.OrderProducts.Add(new OrderProductBinding {
                    Count = 10, ProductId = 1
                });
                model.OrderProducts.Add(new OrderProductBinding {
                    Count = 13, ProductId = 2
                });
                logicP.Create(new ProductBinding {
                    Id = 1, Name = "0", Price = 10
                });
                logicP.Create(new ProductBinding {
                    Id = 2, Name = "1", Price = 5
                });
                logicO.Create(model);

                List <OrderView> list = logicO.Read(null);

                Assert.Equal(2, list[0].OrderProducts.Count);
                Assert.Equal(5, list[0].OrderProducts[1].Price);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #7
0
        public void TestCreateSeveralOPWithSameProductId()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                OrderBinding model = new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                };
                model.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 3
                });
                model.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 2
                });
                logicP.Create(new ProductBinding {
                    Id = 1
                });
                logicO.Create(model);

                List <OrderView> list = logicO.Read(null);

                Assert.Single(list[0].OrderProducts);
                Assert.Equal(1, list[0].OrderProducts[0].ProductId);
                Assert.Equal(5, list[0].OrderProducts[0].Count);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #8
0
 public ActionResult DeleteApplicantEducation([FromBody] OrderPoco[] pocos)
 {
     try
     {
         _logic.Delete(pocos);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Пример #9
0
        public void TestUpdateSeveralOPWithSameProductId()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                logicP.Create(new ProductBinding {
                    Name = "0"
                });
                logicP.Create(new ProductBinding {
                    Name = "1"
                });
                OrderBinding model = new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                };
                model.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 3
                });
                logicO.Create(model);
                OrderView    ov     = logicO.Read(null)[0];
                OrderBinding model2 = new OrderBinding {
                    Id = ov.Id, OrderProducts = new List <OrderProductBinding>()
                };
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 3
                });
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1, Count = 2
                });
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 2, Count = 1
                });
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 2, Count = 5
                });
                logicO.Update(model2);

                List <OrderView> list = logicO.Read(null);

                Assert.Equal(2, list[0].OrderProducts.Count);
                Assert.Equal(1, list[0].OrderProducts[0].ProductId);
                Assert.Equal(5, list[0].OrderProducts[0].Count);
                Assert.Equal(2, list[0].OrderProducts[1].ProductId);
                Assert.Equal(6, list[0].OrderProducts[1].Count);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #10
0
        public void TestDeleteAll()
        {
            OrderLogic   logic = new OrderLogic();
            OrderBinding model = new OrderBinding {
                Id = 1, OrderProducts = new List <OrderProductBinding>()
            };

            logic.Create(model);
            logic.Delete(null);

            List <OrderView> list = logic.Read(null);

            Assert.Empty(list);
        }
Пример #11
0
        public void TestOrderProductAutoId()
        {
            OrderLogic   logicO = new OrderLogic();
            ProductLogic logicP = new ProductLogic();

            try
            {
                OrderBinding model1 = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                OrderBinding model2 = new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                };
                model1.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1
                });
                model1.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 2
                });
                model2.OrderProducts.Add(new OrderProductBinding {
                    ProductId = 1
                });
                logicP.Create(new ProductBinding {
                    Name = "0"
                });
                logicP.Create(new ProductBinding {
                    Name = "1"
                });
                logicO.Create(model1);
                logicO.Create(model2);

                List <OrderView> list = logicO.Read(null);

                Assert.Equal(1, list[0].OrderProducts[0].Id);
                Assert.Equal(2, list[0].OrderProducts[1].Id);
                Assert.Equal(3, list[1].OrderProducts[0].Id);
                Assert.Equal(1, list[0].OrderProducts[0].OrderId);
                Assert.Equal(1, list[0].OrderProducts[1].OrderId);
                Assert.Equal(2, list[1].OrderProducts[0].OrderId);
            }
            finally
            {
                logicO.Delete(null);
                logicP.Delete(null);
            }
        }
Пример #12
0
        public void TestCreate()
        {
            OrderLogic logic = new OrderLogic();

            try
            {
                logic.Create(new OrderBinding {
                    Id = 1, OrderProducts = new List <OrderProductBinding>()
                });

                List <OrderView> list = logic.Read(null);

                Assert.Single(list);
                Assert.Equal(1, list[0].Id);
            }
            finally
            {
                logic.Delete(null);
            }
        }
    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee      e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));

        if (e2.Designation.Equals("COMERCIAL MANAGER") || e2.Designation.Equals("COMERCIAL EMPLOYEE") || e2.Designation.Equals("DESIGNER") || e2.Designation.Equals("PRODUCTION MANAGER") || e2.Designation.Equals("PRODUCTION EMPLOYEE"))
        {
            OrderLogic ol = new OrderLogic();
            Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
            if (o1 != null)
            {
                int i = ol.Delete(o1.OrderID);

                Response.Redirect("OrderList.aspx");
            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }
    }
Пример #14
0
        public void TestMethodSaveOrderWithoutOrderProducts()
        {
            string          message = "";
            OrderLogic      logicO  = new OrderLogic();
            OrderPageDriver driver  = new OrderPageDriver(new UiContext(logicO, new ProductLogic()), null);

            driver.ShowErrorMessage = (msg) => { message = msg; };

            try
            {
                bool             result = driver.SaveOrder();
                List <OrderView> list   = logicO.Read(null);

                Assert.False(result);
                Assert.Empty(list);
                Assert.Equal("List of products is empty", message);
            }
            finally
            {
                logicO.Delete(null);
            }
        }
    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
         EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (e2.Designation.Equals("COMERCIAL MANAGER") || e2.Designation.Equals("COMERCIAL EMPLOYEE") || e2.Designation.Equals("DESIGNER") || e2.Designation.Equals("PRODUCTION MANAGER") || e2.Designation.Equals("PRODUCTION EMPLOYEE"))
        {
            OrderLogic ol = new OrderLogic();
            Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
            if (o1 != null)
            {
                int i = ol.Delete(o1.OrderID);

                Response.Redirect("OrderList.aspx");

            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }

    }
Пример #16
0
 private void ButtonDel_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridOrders.SelectedItems.Count == 1)
     {
         MessageBoxResult result = (MessageBoxResult)MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             int id = ((OrderViewModel)dataGridOrders.SelectedItems[0]).Id;
             try
             {
                 logic.Delete(new OrderBindingModel {
                     Id = id
                 });
             }
             catch (Exception ex)
             {
                 logger.Error("Ошибка удаления данных : " + ex.Message);
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             LoadData();
         }
     }
 }
Пример #17
0
        public void TestOrdersListNotEmpty()
        {
            OrderLogic       orderLogic = new OrderLogic();
            OrdersPageDriver driver     = new OrdersPageDriver(new UiContext(orderLogic, new ProductLogic()));

            try
            {
                orderLogic.Create(new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                });
                orderLogic.Create(new OrderBinding {
                    OrderProducts = new List <OrderProductBinding>()
                });

                List <OrderView> list = driver.GetAllOrders();

                Assert.Equal(2, list.Count);
            }
            finally
            {
                orderLogic.Delete(null);
            }
        }
 public ActionResult DeleteOrder(
     [FromBody] OrderPoco[] pocos)
 {
     _logic.Delete(pocos);
     return(Ok());
 }