public void GetByCustomerId_WhenPassedKnownCustomerId_ShouldReturnOrderRecordForSpecified()
        {
            // Arrange
            var testDataContext = new DataFileData {
                Orders = _testOrders
            };
            var theRepository = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(theRepository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.GetByCustomerId(1);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkObjectResult));

            var foundOrders = (List <OrderRecord>)((OkObjectResult)response).Value;

            Assert.IsInstanceOfType(foundOrders, typeof(List <OrderRecord>));
        }
        public void Get_WhenCalledWithNoParameters_ShouldReturnAllOrders()
        {
            // Arrange
            var testDataContext = new DataFileData {
                Orders = _testOrders
            };
            var repository = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(repository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.Get();

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(ObjectResult));

            var items = (List <OrderRecord>)((ObjectResult)response).Value;

            Assert.AreEqual(1, items.Count);
        }
        public void GetById_WhenExistingIdPassed_ShouldReturnCorrectItem()
        {
            // Arrange
            var testDataContext = new DataFileData {
                Orders = _testOrders
            };
            var theRepository = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(theRepository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.GetById(1);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkObjectResult));

            var foundOrder = (OrderRecord)((OkObjectResult)response).Value;

            Assert.IsInstanceOfType(foundOrder, typeof(OrderRecord));
        }
        public void GetByDate_WhenPassedAValidDate_ShouldReturnAnyOrdersMatchingForDate()
        {
            // Arrange
            var testDataContext = new DataFileData {
                Orders = _testOrders
            };
            var theRepository = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(theRepository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.GetByDate(new DateTime(2019, 11, 18, 3, 14, 27));

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkObjectResult));

            var foundOrders = (List <OrderRecord>)((OkObjectResult)response).Value;

            Assert.IsInstanceOfType(foundOrders, typeof(List <OrderRecord>));
        }
        private void fillSpacesOrder()
        {
            DataTable table = OrdersServices.GetThisOrder(currentItemSelected);

            DatePickerDate.SelectedDate = table.Rows[0]["or_date"] as DateTime?;
            TextBoxName.Text            = table.Rows[0]["or_client_name"].ToString();
            TextBoxPhone.Text           = table.Rows[0]["or_phone"].ToString();
            TextBoxProduct.Text         = table.Rows[0]["or_product_description"].ToString();
            TextBoxPrecio.Text          = table.Rows[0]["or_price"].ToString();
            TextBoxAnticipe.Text        = table.Rows[0]["or_anticipe"].ToString();
            TextBoxObservation.Text     = table.Rows[0]["or_observation"].ToString();
            TextBoxNumeroRecibo.Text    = table.Rows[0]["or_order"].ToString();
            bool state = (bool)table.Rows[0]["or_state"];

            if (state)
            {
                ComboBoxState.SelectedIndex = 1;
            }
            else
            {
                ComboBoxState.SelectedIndex = 0;
            }
            DataTable userData = UsersServices.GetThisUser(table.Rows[0]["or_user_owner"].ToString());

            TextBoxUsuario.Text = userData.Rows[0]["us_name"].ToString() + " " + userData.Rows[0]["us_paterno"].ToString() + " " + userData.Rows[0]["us_materno"].ToString();
        }
        public NegotiatedContentResult <string> TestPushNotification([FromBody] TestPushNotificationRequest request)
        {
            OrdersServices _ordersServices = new OrdersServices();

            _ordersServices.TestPushNotification(request.push_token);
            return(Content(HttpStatusCode.OK, "Notification sent"));
        }
 private void ButtonDelete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         OrdersServices.DeleteThisOrder(currentItemSelected);
         cleanSpaces();
         ShowAllOrders();
         TextBlockMessage.Text = "Eliminado con exito...";
     }
     catch (Exception)
     {
         TextBlockMessage.Text = "No se pudo Elminar...";
     }
 }
예제 #8
0
 public static void UpdateTeleOrderRequest(AddTeleOrderRequest request)
 {
     // To update request from mobile, Reason : not passing expected values from mobile
     foreach (var item in request.products)
     {
         using (ProductDao prodDao = new ProductDao())
         {
             Product product = prodDao.FindProductById(item.product_id);
             OrdersServices.UpdateProductForReq(item, product, false);
             if (request.has_exchange)
             {
                 OrdersServices.UpdateProductExchangeForReq(item, product, request.exchange.ToList(), false);
             }
         }
     }
 }
예제 #9
0
        private async void MandarOrden()
        {
            foreach (var a in LP)
            {
                bool sw = await OrdersServices.TryCreateOrder(a);

                if (sw)
                {
                    MessageBox.Show("Se ha añadido a la orden");
                }
                else
                {
                    MessageBox.Show("Se ha producido un error");
                }
            }
        }
        public void Get_WhenCalledWithNoParameters_ShouldReturnOkObjectResult()
        {
            // Arrange
            var testDataContext = new DataFileData();
            var repository      = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(repository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.Get();

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(ObjectResult));
        }
        public void GetByCustomerId_WhenPassedUnknownCustomerId_ShouldReturnNotFoundResult()
        {
            // Arrange
            var testDataContext = new DataFileData {
                Orders = _testOrders
            };
            var theRepository = new OrdersRepository(new DatabaseFactory(testDataContext));

            var ordersServicesInst = new OrdersServices(theRepository);

            //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>();

            var ordersController = new OrdersController(ordersServicesInst);

            // Act
            var response = ordersController.GetByCustomerId(0);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(NotFoundResult));
        }
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DateTime?date = new DateTime?();
                date = DatePickerDate.SelectedDate;
                bool state = false;
                if (ComboBoxState.SelectedIndex != 0)
                {
                    state = true;
                }

                OrdersServices.InsertOrder(date, TextBoxName.Text, TextBoxPhone.Text, TextBoxProduct.Text, TextBoxPrecio.Text, TextBoxAnticipe.Text, TextBoxObservation.Text, state);
                TextBlockMessage.Text = "Guardado con exito...";
                cleanSpaces();
                ShowAllOrders();
            }
            catch (Exception)
            {
            }
        }
        private void ButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DateTime?date = new DateTime?();
                date = DatePickerDate.SelectedDate;
                bool state = false;
                if (ComboBoxState.SelectedIndex != 0)
                {
                    state = true;
                }

                OrdersServices.UpdateThisOrder(date, TextBoxName.Text, TextBoxPhone.Text, TextBoxProduct.Text, TextBoxPrecio.Text, TextBoxAnticipe.Text, TextBoxObservation.Text, state, currentItemSelected);
                TextBlockMessage.Text = "Actualizado con exito...";
                cleanSpaces();
                ShowAllOrders();
            }
            catch (Exception)
            {
                TextBlockMessage.Text = "Ha Ocurrido un error...";
            }
        }
예제 #14
0
 public OrdersController(IConfiguration configuration)
 {
     this.connectionString = configuration.GetConnectionString("ConnectionString");
     this.OrdersService    = new OrdersServices(new OrdersRepository(connectionString));
 }
 private void ShowAllOrders()
 {
     DataGridOrders.ItemsSource = OrdersServices.GetAllOrders().DefaultView;
 }
        private void ButtonBuscar_Click(object sender, RoutedEventArgs e)
        {
            DataTable table = OrdersServices.FindThisOrder(TBSClientName.Text, TBSProduct.Text, DPSDate.Text);

            DataGridOrders.ItemsSource = table.DefaultView;
        }