public void GetOrdersInPriceRangeTest()
        {
            var TestListOfOrders = new List <Order>();

            TestListOfOrders.Add(new Order("1", 1, "Bułka", 1, 10.0));;
            TestListOfOrders.Add(new Order("2", 1, "Chleb", 1, 10.0));

            orderRaports.GetOrdersInPriceRange(10.0, 14.0).Should().BeEquivalentTo(TestListOfOrders);
        }
Example #2
0
        private void minMaxOkBtn_Click(object sender, EventArgs e)
        {
            double minPrice  = double.Parse(minTextBox.Text);
            double maxPrice  = double.Parse(maxTextBox.Text);
            var    dataTable = PopulateColums();

            foreach (var val in orderRaports.GetOrdersInPriceRange(minPrice, maxPrice))
            {
                dataTable.Rows.Add(val.ClientId, val.RequestId, val.Name, val.Quantity, val.Price);
            }

            dataGridView.DataSource = dataTable;
        }
Example #3
0
        public void SaveFile(string path, char selectedMenu, string clientId, double min, double max)
        {
            using (StreamWriter streamWriter = new StreamWriter(path))
            {
                StringBuilder stringBuilder = new StringBuilder();
                switch (selectedMenu)
                {
                case 'A':
                {
                    var result = _orderRaports.GetOrderAmount();
                    stringBuilder.AppendLine($"Order amount:, {result}");
                    break;
                }

                case 'B':
                {
                    var result = _orderRaports.GetOrderAmountPerClient(clientId);
                    stringBuilder.AppendLine($"Order amount for client with id '{clientId}':, {result}");
                    break;
                }

                case 'C':
                {
                    var result = _orderRaports.GetTotalPriceOfOrders();
                    stringBuilder.AppendLine($"Total Price of orders':, {result}");
                    break;
                }

                case 'D':
                {
                    var result = _orderRaports.GetTotalPriceOfOrdersPerClient(clientId);
                    stringBuilder.AppendLine($"Total price of orders for client with id '{clientId}':, {result}");
                    break;
                }

                case 'E':
                {
                    stringBuilder.AppendLine("ClientId,RequestId,Name,Quantity,Price");
                    foreach (var val in _orderRaports.GetTotalListOfOrders())
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}",
                                                               val.ClientId, val.RequestId, val.Name, val.Quantity, val.Price));
                    }
                    break;
                }

                case 'F':
                {
                    stringBuilder.AppendLine("ClientId,RequestId,Name,Quantity,Price");
                    foreach (var val in _orderRaports.GetTotalListOfOrdersPerClient(clientId))
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}",
                                                               val.ClientId, val.RequestId, val.Name, val.Quantity, val.Price));
                    }
                    break;
                }



                case 'I':
                {
                    stringBuilder.AppendLine("Name,AmountOfOrders");
                    foreach (var val in _orderRaports.GetAmountOfOrdersGroupedByName())
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1}", val.Key, val.Value));
                    }
                    break;
                }

                case 'J':
                {
                    stringBuilder.AppendLine("Name,AmountOfOrders");
                    foreach (var val in _orderRaports.GetAmountOfOrdersGroupedByNamePerClient(clientId))
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1}", val.Key, val.Value));
                    }
                    break;
                }

                case 'K':
                {
                    stringBuilder.AppendLine("ClientId,RequestId,Name,Quantity,Price");
                    foreach (var val in _orderRaports.GetOrdersInPriceRange(min, max))
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}",
                                                               val.ClientId, val.RequestId, val.Name, val.Quantity, val.Price));
                    }
                    break;
                }
                }
                streamWriter.Write(stringBuilder.ToString());
            }
        }