Exemple #1
0
        public void Execute()
        {
            bool keepRunning = true;

            do
            {
                Console.Clear();
                Manager order = ManagerFactory.Create();
                Console.WriteLine("Displaying an Order");
                Console.WriteLine(UserIO.Separator);
                Console.WriteLine("Please enter a Date:");
                string   userInput = "MM/dd/yyyy";
                DateTime date      = DateTime.Parse("06-01-2013");
                if (!DateTime.TryParse(Console.ReadLine(), out date))
                {
                    Console.WriteLine("Please enter format in {0}", userInput);
                    Console.WriteLine("Press any key to continue....");
                    Console.ReadKey();
                    return;
                }
                DisplayResponse response = order.DisplayOrder(date);
                if (response.Success)
                {
                    UserIO.DisplayOrderDetail(response.Orders);
                    Console.ReadKey();
                }
                return;
            } while (keepRunning);
        }
Exemple #2
0
 public void Execute(DisplayResponse port)
 {
     foreach (string s in GetList())
     {
         port(s);
     }
 }
Exemple #3
0
        public void LoadResponse()
        {
            DateTime date = new DateTime(2020, 06, 06);

            List <Orders> orders = repo.LoadOrders(date);

            DisplayResponse response = manager.DisplayOrder(date);

            Assert.IsNotNull(response.Orders);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(date, response.Orders.FirstOrDefault(o => o.dateTime == date).dateTime);
        }
Exemple #4
0
        //LoadOrders checks to see if the order exists in repository and loads it if it does
        public DisplayResponse LoadOrders(DateTime date)
        {
            DisplayResponse response = new DisplayResponse();

            response.OrderInfoList = _orderRepo.LoadOrders(date);

            if (response.OrderInfoList == null)
            {
                response.Success = false;
                response.Message = $"an order for {date} could not be found.";//another message prints if no orders are found. Maybe this only prints in the case
            }
            else
            {
                response.Success = true;
            }
            return(response);
        }
Exemple #5
0
        public DisplayResponse DisplayOrder(DateTime date)
        {
            DisplayResponse response = new DisplayResponse()
            {
                Orders = _orderRepository.LoadOrders(date)
            };

            if (response.Orders == null)
            {
                response.Success = false;
                response.Message = $"{date} is not a valid date";
                Console.ReadKey();
                return(response);
            }
            else
            {
                response.Success = true;
            }
            return(response);
        }
Exemple #6
0
        //REMEMBER: this workflow only handles displaying orders. There's separate workflows for creating, editing, and removing accounts
        public void Execute()
        {
            // make a new orderManager object by calling up the AMFactory's create method
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Enter a date (e.g. 06/01/2013) to view the orders for that day");

            DateTime userDateInput = manager.StringToDate(Console.ReadLine());

            DisplayResponse response = manager.LoadOrders(userDateInput);

            if (response.Success)
            {
                ConsoleIO.DisplayDetails(response.OrderInfoList, userDateInput);
            }
            else
            {
                Console.WriteLine("There are no orders for that date in the system");
            }
            Console.WriteLine("press any key to go back to the menu");
            Console.ReadKey();
        }
        public async Task <DisplayResponse> GetDisplay(string display)
        {
            DisplayResponse result = new DisplayResponse();

            result.Success = true;
            if (IsDebugMode)
            {
                Logger.Debug($"Sent popper request for {display} feed");

                string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string localFilename = "test.m4v";
                //Slight hacky fudge
                if (display.Equals("Wheel", StringComparison.CurrentCultureIgnoreCase))
                {
                    localFilename = "test.png";
                }

                result.MediaUrl = localFilename;
            }
            else
            {
                GetDisplayRequest request = new GetDisplayRequest();
                request.display = display;

                var response = await _api.MakeRequest <GetDisplayRequest, string>(request).ConfigureAwait(false);

                if (response.Success == true)
                {
                    try
                    {
                        if (string.Equals(response.Data, "no image found", StringComparison.CurrentCultureIgnoreCase))
                        {
                            Logger.Error($"Error fetching display {display}, no image found returned from Popper");
                            //TODO Change to an actual response object instead of string
                            result.Success = false;
                            result.Error   = string.Format($"Error - No image found");
                        }
                        else
                        {
                            // Check Response data to determine what format to save the byte[] too
                            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                            string localFilename = "test.txt";
                            if (response.Data.Contains("video") ||
                                response.Data.Contains("image"))
                            {
                                string format = response.Data.Split('/')[1];
                                localFilename = $"test.{format}";
                            }

                            // Save
                            string localPath = Path.Combine(documentsPath, localFilename);
                            File.WriteAllBytes(localPath, response.Raw);

                            result.MediaUrl = localPath;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"Error saving off display data for playback - {ex.Message}", ex);
                        result.Success = false;
                        result.Error   = $"Error saving off display data for playback - {ex.Message}";
                    }
                }
                else
                {
                    Logger.Error($"Error requesting Display {display}, responded with {response?.Code} and {response?.Messsage}");
                    result.Success = false;
                    result.Error   = $"Error requesting Display { display}, responded with { response?.Code} and { response?.Messsage}";
                }
            }

            return(result);
        }
 public void Execute(DisplayResponse port)
 {
     observedPort = port;
     port(outText);
 }
Exemple #9
0
        // this checks to see if a file exists. If it does it returns a list of OrderInfos
        public List <OrderInfo> LoadOrders(DateTime userInputDate)
        {
            string fileNameDate = String.Format(userInputDate.ToString("MMddyyyy"));
            string dirPathFile  = ($"{_dirPath}\\Orders_{fileNameDate}.txt");

            DisplayResponse response = new DisplayResponse()
            {
                Success       = false,
                Message       = "something went wrong in the orderInfoRepo",
                OrderInfoList = null
            };

            if (File.Exists(dirPathFile))
            {
                List <OrderInfo> orders = new List <OrderInfo>();
                using (StreamReader sr = new StreamReader(dirPathFile))
                {
                    sr.ReadLine();
                    string line;

                    while ((line = sr.ReadLine()) != null)//calculate the vals here from tax/products repo
                    {
                        OrderInfo newOrderInfo = new OrderInfo();

                        string[] columns = line.Split(',');

                        //add date todo
                        newOrderInfo.OrderDate    = userInputDate;
                        newOrderInfo.OrderNumber  = int.Parse(columns[0]);
                        newOrderInfo.CustomerName = columns[1];
                        newOrderInfo.StateTax     = _taxStuff.GetStateTax(columns[2]);
                        //newOrderInfo.TaxRate = decimal.Parse(columns[3]);
                        newOrderInfo.OrderProduct = _productStuff.GetProduct(columns[4]);
                        newOrderInfo.Area         = decimal.Parse(columns[5]);
                        //newOrderInfo.CostPerSquareFoot = decimal.Parse(columns[6]);
                        //newOrderInfo.LaborCostPerSquareFoot = decimal.Parse(columns[7]);
                        //newOrderInfo.MaterialCost = decimal.Parse(columns[8]); ALREADY CALCULATED IN CLASS DEFINITION
                        //newOrderInfo.LaborCost = decimal.Parse(columns[9]);
                        //newOrderInfo.Tax = decimal.Parse(columns[10]);
                        //newOrderInfo.Total = decimal.Parse(columns[11]);

                        orders.Add(newOrderInfo);
                    }
                }
                //these responses and the return are out of sync with the orderManager
                response.Success       = true;
                response.OrderInfoList = orders;
                response.Message       = "it worked";

                return(response.OrderInfoList);
                //return response with order, success, message saying it worked
            }
            else
            {
                response.Success       = false;
                response.OrderInfoList = null;
                response.Message       = "nothing for that date";

                return(response.OrderInfoList);
            }
        }