public WorkflowUtilities()
 {
     this._flexableDto = new OrderDto();
     this._validate = new ValidationTools();
     this._stateBus = new StateBusiness();
     this._prodBus = new ProductBusiness();
 }
예제 #2
0
 public AddOrderWF()
 {
     this._exportDto = new OrderDto();
     this._submit = new OrderManager();
     this._response = new Response<RepoReceipt>();
     this._util = new WorkflowUtilities();
 }
예제 #3
0
        public Response<RepoReceipt> EditOrder(OrderDto inDto)
        {
            var result = new Response<RepoReceipt>();

            result.Data = _repo.EditOrder(inDto);

            return ProcessResult(result, "Edit Successful", "Edit Failed");
        }
예제 #4
0
        public void Execute()
        {
            string userInput = "";

            do
            {
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                _exportDto = _util.GetCustomerName();
                if (_exportDto.CustomerName == "Q")
                    break;
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                _exportDto = _util.GetSquareFootage();
                if (_exportDto.CustomerName == "Q")
                    break;
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                _exportDto = _util.GetStateAbbv();
                if (_exportDto.CustomerName == "Q")
                    break;
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                _exportDto = _util.GetProductType();
                if (_exportDto.CustomerName == "Q")
                    break;
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                _exportDto.Date = _util.GetAddDate();
                if (_exportDto.Date == DateTime.MaxValue)
                    break;
                _util.DrawFormPriorToSubmissionResponse(_exportDto);

                do
                {
                    Console.WriteLine("\nPress 'S' to submit, 'R' to retry, or 'Q' to quit...");
                    userInput = Console.ReadLine().ToLower();
                } while (userInput != "r" && userInput != "s" && userInput != "q");

                switch (userInput)
                {
                    case "s":
                        _response = _submit.AddOrder(_exportDto);
                        _util.DrawFormFullyPopulatedAfterOrderAdded(_exportDto, _response);
                        Console.WriteLine(_response.Message);
                        Console.ReadKey();
                        break;
                    case "q":
                        break;
                    case "r":
                        _exportDto = new OrderDto();
                        break;
                }
            } while (userInput == "r");
        }
예제 #5
0
        public void Execute()
        {
            string input = "";

            do
            {
                Console.Clear();
                Displays.Displays.ManageOrdersMenu();
                Displays.Displays.EnterChoice();

                input = Console.ReadLine().ToUpper();

                switch (input)
                {
                    case "L":
                        _tryAgain = false;
                        _currentDto = LookupOrder();
                        if (_tryAgain)
                            break;
                        _util.DrawFormWithPreExistingDto(_currentDto);
                        Console.WriteLine("Order lookup successful.");
                        Console.WriteLine("Press enter to continue...");
                        Console.ReadLine();
                        break;
                    case "M":
                        _tryAgain = false;
                        _currentDto = LookupOrder();
                        if (_tryAgain)
                            break;
                        _util.DrawFormWithPreExistingDto(_currentDto);
                        _currentDto = ModifyOrder(_currentDto);
                        _submit.EditOrder(_currentDto);
                        break;
                    case "D":
                        _tryAgain = false;
                        _currentDto = LookupOrder();
                        if (_tryAgain)
                            break;
                        _util.DrawFormWithPreExistingDto(_currentDto);
                        bool delete = DeleteOrder();
                        if (delete)
                        {
                            var response1 = _submit.DeleteOrder(_date, _id);
                            Console.WriteLine(response1.Message);
                            Console.ReadLine();
                        }
                        break;
                    case "Q":
                        break;
                }
            } while (input != "Q");
        }
예제 #6
0
        public RepoReceipt AddOrder(OrderDto inDto)
        {
            var result = new RepoReceipt();
            List<OrderDto> listOfOrder = GetOrderListByDate(inDto);

            try
            {
                foreach (var o in listOfOrder)
                {
                    // DOF exists
                    if (inDto.FileName == o.FileName)
                    {
                        var listOfOrderById = listOfOrder.OrderByDescending(x => x.ID).Take(1);
                        inDto.ID = listOfOrderById.ElementAt(0).ID + 1;
                        AddOrderRecord(inDto);
                        result.Success = true;
                        result.Date = inDto.Date;
                        result.ID = inDto.ID;
                        result.Message = "Order add successful, new order id:" + result.ID;
                        break;
                    }

                    // no DOF on file - need brand new DOF file
                    else
                    {
                        inDto.ID = 1;
                        AddNewOrderFile(inDto);
                        result.Success = true;
                        result.Date = inDto.Date;
                        result.ID = inDto.ID;
                        result.Message = "Order add successful, new order id:" + result.ID;
                    }
                }
            }

            catch (Exception ex)
            {
                result.Success = false;
                result.IsFailLoggable = true;
                result.Message = "He's DEAD Jim! - {0}" + ex.Message;
            }

            return result;
        }
        public void DrawFormFullyPopulatedAfterOrderAdded(OrderDto dto, Response<RepoReceipt> response)
        {
            var date = dto.Date.ToShortDateString();

            Console.Clear();
            Console.WriteLine("                     <FoS Order Systems>");
            Console.WriteLine();
            Console.WriteLine("=================================================================");
            Console.WriteLine(format, dto.CustomerName);
            Console.WriteLine();
            Console.WriteLine(format1, dto.State, response.Data.ID);
            Console.WriteLine(format2, dto.ProdType, date);
            Console.WriteLine(format3, dto.FloorArea, dto.TotalMaterials);
            Console.WriteLine(format4, dto.MaterialsPsF, dto.TotalLabor);
            Console.WriteLine(format5, dto.LaborPsF, dto.TotalCostPreTax);
            Console.WriteLine(format6, dto.TaxRate, dto.TotalTax);
            Console.WriteLine(format7, dto.TotalCost);
            Console.WriteLine("=================================================================");
            Console.WriteLine();
        }
예제 #8
0
        public RepoReceipt AddOrder(OrderDto inDto)
        {
            var result = new RepoReceipt();

            try
            {
                var orderList = ListOfOrder.OrderByDescending(x => x.ID).Take(1);
                inDto.ID = orderList.ElementAt(0).ID + 1;
                ListOfOrder.Add(inDto);
                result.Success = true;
                result.Date = inDto.Date;
                result.ID = inDto.ID;
                result.Message = "TEST Order Add Succsefful, new order id:" + result.ID;
            }

            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "He's DEAD Jim! - {0}" + ex.Message;
            }

            return result;
        }
        public void DrawFormPriorToSubmissionResponse(OrderDto dto)
        {
            var date = dto.Date.ToShortDateString();

            if (dto.Date == DateTime.MinValue)
                date = "";

            Console.Clear();
            Console.WriteLine("                       <FoS Order Systems>");
            Console.WriteLine();
            Console.WriteLine("=================================================================");
            Console.WriteLine(format, dto.CustomerName);
            Console.WriteLine();
            Console.WriteLine(format1, dto.State, "");
            Console.WriteLine(format2, dto.ProdType, date);
            Console.WriteLine(format3, dto.FloorArea, dto.TotalMaterials);
            Console.WriteLine(format4, dto.MaterialsPsF, dto.TotalLabor);
            Console.WriteLine(format5, dto.LaborPsF, dto.TotalCostPreTax);
            Console.WriteLine(format6, dto.TaxRate, dto.TotalTax);
            Console.WriteLine(format7, dto.TotalCost);
            Console.WriteLine("=================================================================");
            Console.WriteLine("              *** Enter \"Q\" at any time to quit ***");
            Console.WriteLine();
        }
예제 #10
0
        public RepoReceipt EditOrder(OrderDto inDto)
        {
            var result = new RepoReceipt();

            var dofList = GetOrderListByDate(inDto);

            try
            {
                dofList = dofList.Where(o => !(o.Date.Date == inDto.Date.Date && (o.ID.Equals(inDto.ID)))).ToList();
                dofList.Add(inDto);
                DeleteOrderFile(inDto);
                AddNewOrderFileAndHeaderOnly(inDto);

                foreach (var o in dofList)
                {
                    AddOrderRecord(o);
                }

                result.Success = true;
                result.Message = "Order updated.";
                result.Date = inDto.Date;
                result.ID = inDto.ID;
            }

            catch (Exception ex)
            {
                result.Success = false;
                result.IsFailLoggable = true;
                result.Message = "He's DEAD Jim! - {0}" + ex.Message;
            }

            return result;
        }
예제 #11
0
 public ManageOrderWF()
 {
     this._currentDto = new OrderDto();
     this._submit = new OrderManager();
     this._util = new WorkflowUtilities();
 }
예제 #12
0
        public RepoReceipt DeleteOrder(DateTime inDate, int inID)
        {
            var result = new RepoReceipt();
            var dto = new OrderDto(inDate);
            var lookupResponse = LookUpSingleOrder(inDate, inID);

            try
            {
                // subject order record exists
                if (lookupResponse.Success)
                {
                    int dofOrderCount = GetDOfOrderCount(ListAllOrders(), inDate);

                    // no other order exists
                    if (dofOrderCount == 1)
                    {
                        DeleteOrderFile(dto);
                        result.Success = true;
                        result.Message = "Order deleted.";
                        result.ID = inID;
                        result.Date = dto.Date;
                    }

                    // many orders in DOF
                    else
                    {
                        var dtoList = GetOrderListByDate(dto).Where(o => !o.ID.Equals(inID));

                        DeleteOrderFile(dto);

                        AddNewOrderFileAndHeaderOnly(dto);

                        foreach (var o in dtoList)
                        {
                            AddOrderRecord(o);
                        }

                        result.Success = true;
                        result.Message = "Order deleted.";
                        result.ID = inID;
                        result.Date = dto.Date;

                    }
                }

                else
                {
                    result.Success = false;
                    Console.ForegroundColor = ConsoleColor.Red;
                    result.Message = "Cannot delete - Order not found...";
                    Console.ResetColor();
                }
            }

            catch (Exception ex)
            {
                result.Success = false;
                result.IsFailLoggable = true;
                result.Message = "He's DEAD Jim! - {0}" + ex.Message;
            }

            return result;
        }
예제 #13
0
        //
        private List<OrderDto> GetOrderListByDate(OrderDto inDto)
        {
            List<OrderDto> resultList = new List<OrderDto>();

            bool isFile = File.Exists(Path.Combine(_filePath, inDto.FileName));

            if (isFile)
            {
                var reader = File.ReadAllLines(Path.Combine(_filePath, inDto.FileName));

                for (int i = 1; i < reader.Length; i++)
                {
                    var columns = reader[i].Split(',');

                    var resultDto = new OrderDto();

                    resultDto.ID = int.Parse(columns[0]);
                    resultDto.CustomerName = (columns[1]);
                    resultDto.State = (columns[2]);
                    resultDto.TaxRate = decimal.Parse(columns[3]);
                    resultDto.ProdType = (columns[4]);
                    resultDto.FloorArea = decimal.Parse(columns[5]);
                    resultDto.MaterialsPsF = decimal.Parse(columns[6]);
                    resultDto.LaborPsF = decimal.Parse(columns[7]);
                    resultDto.Date = DateTime.Parse(columns[12]);

                    resultList.Add(resultDto);

                }
            }

            else
            {
                var emptyDto = new OrderDto();
                resultList.Add(emptyDto);
            }

            return resultList;
        }
예제 #14
0
        // all Order(s)
        private List<OrderDto> GetListOfOrder()
        {
            string[] dofList = GetDOFList();

            var resultList = new List<OrderDto>();

            foreach (string dof in dofList)
            {
                var reader = File.ReadAllLines(dof);

                for (int i = 1; i < reader.Length; i++)
                {
                    var columns = reader[i].Split(',');

                    var resultDto = new OrderDto();

                    resultDto.ID = int.Parse(columns[0]);
                    resultDto.CustomerName = (columns[1]);
                    resultDto.State = (columns[2]);
                    resultDto.TaxRate = decimal.Parse(columns[3]);
                    resultDto.ProdType = (columns[4]);
                    resultDto.FloorArea = decimal.Parse(columns[5]);
                    resultDto.MaterialsPsF = decimal.Parse(columns[6]);
                    resultDto.LaborPsF = decimal.Parse(columns[7]);
                    resultDto.Date = DateTime.Parse(columns[12]);

                    resultList.Add(resultDto);
                }
            }

            return resultList;
        }
예제 #15
0
 private void DeleteOrderFile(OrderDto dto)
 {
     if (File.Exists(Path.Combine(_filePath, dto.FileName)))
     {
         File.Delete(Path.Combine(_filePath, dto.FileName));
     }
 }
예제 #16
0
 private void AddOrderRecord(OrderDto dto)
 {
     using (var logger = File.AppendText(Path.Combine(_filePath, dto.FileName)))
     {
         logger.WriteLine(dto.OrderRecord);
     }
 }
예제 #17
0
 private void AddNewOrderFileAndHeaderOnly(OrderDto dto)
 {
     using (var logger = File.AppendText(Path.Combine(_filePath, dto.FileName)))
     {
         logger.WriteLine(dto.OrderHeader);
     }
 }
예제 #18
0
        private OrderDto ModifyOrder(OrderDto dto)
        {
            string choice;
            string input;

            var originalName = dto.CustomerName;
            var originalArea = dto.FloorArea;
            var originalState = dto.State;
            var originalTax = dto.TaxRate;
            var originalProd = dto.ProdType;
            var originalMatPsf = dto.MaterialsPsF;
            var originalLabPsf = dto.LaborPsF;

            do
            {
                Console.WriteLine("Please choose from the following...");
                Console.WriteLine("(C)ustomer Name");
                Console.WriteLine("(F)loored Area");
                Console.WriteLine("(S)tate");
                Console.WriteLine("(P)roduct Type");
                Console.WriteLine("** Any other key to quit **");

                choice = Console.ReadLine().ToUpper();

                if (choice == "C" || choice == "F" || choice == "S" || choice == "P")
                switch (choice)
                {
                    case "C":
                        dto.CustomerName = _util.GetCustomerName().CustomerName;
                        break;
                    case "F":
                        dto.FloorArea = _util.GetSquareFootage().FloorArea;
                        break;
                    case "S":
                        var response = _util.GetStateAbbv();
                        dto.State = response.State;
                        dto.TaxRate = response.TaxRate;
                        break;
                    case "P":
                        var response1 = _util.GetProductType();
                        dto.ProdType = response1.ProdType;
                        dto.LaborPsF = response1.LaborPsF;
                        dto.MaterialsPsF = response1.MaterialsPsF;
                        break;
                }
                Console.Clear();
                _util.DrawFormWithPreExistingDto(dto);
                Console.WriteLine("(M)odify another field");
                Console.WriteLine("(S)ave and quit");
                Console.WriteLine("** Any other key to quit without saving **");
                input = Console.ReadLine().ToUpper();

                if (input == "S")
                {
                    Console.WriteLine("Modifications saved.  Press any key to continue...");
                    Console.ReadKey();
                    return dto;
                }

            } while (input == "M");

            dto.CustomerName = originalName;
            dto.FloorArea = originalArea;
            dto.State = originalState;
            dto.TaxRate = originalTax;
            dto.ProdType = originalProd;
            dto.MaterialsPsF = originalMatPsf;
            dto.LaborPsF = originalLabPsf;

            return dto;
        }
예제 #19
0
        public RepoReceipt EditOrder(OrderDto inDto)
        {
            var result = new RepoReceipt();

            int inDtoID = 0;

            try
            {
                foreach (var o in ListOfOrder)
                {
                    if (o.Date.Date == inDto.Date && o.ID == inDto.ID)
                    {
                        inDtoID = o.ID;
                        ListOfOrder.Remove(o);
                        break;
                    }
                }

                inDto.ID = inDtoID;

                ListOfOrder.Add(inDto);

                result.Success = true;
                result.Message = "TEST Order Edit sucessful.";
                result.Date = inDto.Date;
                result.ID = inDto.ID;
            }

            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "He's DEAD Jim! - {0}" + ex.Message;
            }

            return result;
        }
예제 #20
0
 public void DrawFormWithPreExistingDto(OrderDto dto)
 {
     Console.Clear();
     Console.WriteLine("                     <FoS Order Systems>");
     Console.WriteLine();
     Console.WriteLine("=================================================================");
     Console.WriteLine(format, dto.CustomerName);
     Console.WriteLine();
     Console.WriteLine(format1, dto.State, dto.ID);
     Console.WriteLine(format2, dto.ProdType, dto.Date);
     Console.WriteLine(format3, dto.FloorArea, dto.TotalMaterials);
     Console.WriteLine(format4, dto.MaterialsPsF, dto.TotalLabor);
     Console.WriteLine(format5, dto.LaborPsF, dto.TotalCostPreTax);
     Console.WriteLine(format6, dto.TaxRate, dto.TotalTax);
     Console.WriteLine(format7, dto.TotalCost);
     Console.WriteLine("=================================================================");
     Console.WriteLine();
 }