public void TestDeleteOrder()
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            Expect.Once.On(service).Method("DeleteOrder").Will(Return.Value(response));
            serviceFacade.DeleteOrder(1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete order by request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public DeleteOrderResponse DeleteOrder(DeleteOrderRequest request)
        {
            DeleteOrderResponse response            = new DeleteOrderResponse();
            OrderService        service             = new OrderService();
            OrderDetailsService orderDetailsService = new OrderDetailsService();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    bool result = service.DeleteOrder(request.OrderId);
                    bool deleteOrderDetailsResult = orderDetailsService.CloseOrderDetailsByOrderID(request.OrderId);
                    if (result && deleteOrderDetailsResult)
                    {
                        scope.Complete();
                    }
                }
            }
            catch (TransactionAbortedException ex)
            {
                response.IsFailed = true;
                response.Message  = ex.Message;
            }
            catch (Exception ex)
            {
                response.IsFailed = true;
                response.Message  = ex.Message;
            }

            return(response);
        }
        public void TestDeleteResponse(int year, int month, int day, string customerName, int orderNumber, string state, decimal taxRate, string productType, decimal area,
                                       decimal costPerSquareFoot, decimal laborCostPerSquareFoot, decimal materialCost, decimal laborCost, decimal tax, decimal total, bool expectedResult)
        {
            OrderManager manager = OrderManagerFactory.Create();
            Order        ord     = new Order();

            ord.Date                   = new DateTime(year, month, day);
            ord.CustomerName           = customerName;
            ord.OrderNumber            = orderNumber;
            ord.State                  = state;
            ord.TaxRate                = taxRate;
            ord.ProductType            = productType;
            ord.Area                   = area;
            ord.CostPerSquareFoot      = costPerSquareFoot;
            ord.LaborCostPerSquareFoot = laborCostPerSquareFoot;
            ord.MaterialCost           = materialCost;
            ord.LaborCost              = laborCost;
            ord.Tax   = tax;
            ord.Total = total;
            DeleteOrderResponse response = manager.OrderDelete(ord.Date, orderNumber);

            if (response.Success)
            {
                Assert.IsNotNull(response.order);
                Assert.AreEqual(response.order.CustomerName, customerName);
                Assert.AreEqual(response.order.Date, ord.Date);
                Assert.AreEqual(response.order.State, state);
                Assert.AreEqual(response.order.Area, area);
            }
            Assert.AreEqual(expectedResult, response.Success);
        }
Exemplo n.º 4
0
        public void CanDeleteOrder(int orderNumber, string date, bool expected)
        {
            DateTime orderDate = DateTime.Parse(date);
            Order    _order    = new Order
            {
                OrderDate              = DateTime.Parse("08/07/2020"),
                OrderNumber            = 100,
                CustomerName           = "Chuck Testa",
                State                  = "OH",
                TaxRate                = 6.25m,
                ProductType            = "Carpet",
                Area                   = 100.5m,
                CostPerSquareFoot      = 2.25m,
                LaborCostPerSquareFoot = 2.25m,
            };

            OrderManager     orderManager     = new OrderManager(orderRepo);
            AddOrderResponse addOrderResponse = orderManager.AddOrder(_order);


            OrderLookupResponse orderLookup = orderManager.LookupOrder(orderNumber, orderDate);

            if (orderLookup.Success)
            {
                DeleteOrderResponse deleteOrderResponse = orderManager.DeleteOrder(orderLookup.Order);
                Assert.AreEqual(expected, deleteOrderResponse.Success);
            }
            else
            {
                Assert.AreEqual(expected, orderLookup.Success);
            }
        }
        public DeleteOrderResponse Delete(Order order)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            _or.Delete(order);
            response.Success = true;
            return(response);
        }
Exemplo n.º 6
0
        public DeleteOrderResponse DeleteOrder(DeleteOrderRequest request)
        {
            DeleteOrderResponse    response = new DeleteOrderResponse();
            OrderBusinessComponent bc       = DependencyInjectionHelper.GetOrderBusinessComponent();

            bc.DeleteOrder(request.Id);

            return(response);
        }
Exemplo n.º 7
0
        public DeleteOrderResponse DeleteOrder(DeleteOrderRequest request)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();
            OrderBusinessComponent bc = DependencyInjectionHelper.GetOrderBusinessComponent();

            bc.DeleteOrder(request.Id);

            return response;
        }
        public static DeleteOrderResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteOrderResponse deleteOrderResponse = new DeleteOrderResponse();

            deleteOrderResponse.HttpResponse = context.HttpResponse;
            deleteOrderResponse.RequestId    = context.StringValue("DeleteOrder.RequestId");

            return(deleteOrderResponse);
        }
Exemplo n.º 9
0
        public void Execute()
        {
            string date;
            int    order;

            Console.Clear();
            Console.WriteLine("Please Enter the following information ");


            Console.Write("Order Date <MM/DD/YYY>: ");
            date = Console.ReadLine();

            Console.Write("Order Number : ");
            order = Convert.ToInt32(Console.ReadLine());


            string placeOrder = "";

            while (true)
            {
                Console.Clear();
                // Once caculations are completed (tax/product information), show summary with information
                //Output.DisplayIO.DisplayOrderSummary();
                IndividualOrderResponse orderResponse = OrderManagerFactory.Create().LocateOrder(date, order);
                if (orderResponse.Success)
                {
                    Output.DisplayIO.DisplayOrderSummary(date, orderResponse.Order);

                    //Console.WriteLine("TODO: DisplySummary of Order BEFORE Removing to Respository");
                    Console.Write("Do you want to remove the order (Y/N): ");
                    placeOrder = Console.ReadLine();
                    switch (placeOrder)
                    {
                    case "Y":
                        //Saved order number for the next availabe order #
                        DeleteOrderResponse deleteOrder = OrderManagerFactory.Create().DeleteOrder(date, order);
                        Console.WriteLine($"Removing from repository: {deleteOrder.Success}");
                        Console.ReadKey();
                        return;

                    case "N":
                        Console.WriteLine($"You will not remove Order {order} from repository");
                        Console.ReadKey();
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(orderResponse.Message);
                    Console.ReadKey();
                    break;
                }
            }
        }
Exemplo n.º 10
0
        public DeleteOrderResponse DeleteOrder(DateTime orderDate, int orderNumber)
        {
            DeleteOrderResponse deleteOrderResponse = new DeleteOrderResponse();

            deleteOrderResponse.DeletedOrder = _orderRepository.LoadOrder(orderDate, orderNumber);
            deleteOrderResponse.Success      = _orderRepository.Delete(orderDate, orderNumber);

            if (!deleteOrderResponse.Success)
            {
                deleteOrderResponse.Message = "The Order was not successfully removed. Please try again.";
            }
            return(deleteOrderResponse);
        }
        public void Execute()
        {
            Console.Clear();
            Console.WriteLine("Removing an Order");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~");
            DateTime date;

            Console.WriteLine("Enter the order date please. Example 01/12/2020: ");
            string inputDate = Console.ReadLine();

            DateTime.TryParse(inputDate, out date);
            Console.WriteLine("Enter the order number please.");
            string orderNum = Console.ReadLine();

            int.TryParse(orderNum, out int orderNumber);
            OrderLookupResponse allResponse = manager.LookupOrder(date, orderNumber);

            if (allResponse.Success)
            {
                ConsoleIO.DisplayOrderDetails(allResponse.order);
            }
            else
            {
                Console.WriteLine("There are no orders in that day. Press enter to continue");
                Console.ReadKey();
                return;
            }


            Console.WriteLine("Are you sure you want to delete this order? y/n");
            string answer = Console.ReadLine().ToLower();

            if (answer == "y")
            {
                DeleteOrderResponse response = manager.OrderDelete(date, orderNumber);
                Console.WriteLine("Your order has been deleted");
            }
            else if (answer == "n")
            {
                Console.WriteLine("Order delete has been canceled");
            }
            else
            {
                Console.WriteLine("An error has occured: ");
                Console.WriteLine(allResponse.Message);
            }
            Console.WriteLine("Press any key to continue..");
            Console.ReadKey();
        }
Exemplo n.º 12
0
        public DeleteOrderResponse OrderDelete(DateTime Date, int OrderNumber)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            response.order = _orderRepository.DeleteOrder(Date, OrderNumber);
            if (response.order == null)
            {
                response.Success = false;
                response.Message = $"Error: {Date} is not an existing order";
            }
            else
            {
                response.Success = true;
            }
            return(response);
        }
Exemplo n.º 13
0
 public void DeleteOrder(int orderId)
 {
     try
     {
         DeleteOrderRequest request = new DeleteOrderRequest();
         request.Id = orderId;
         DeleteOrderResponse response = Service.DeleteOrder(request);
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "PL Policy"))
         {
             throw;
         }
     }
 }
Exemplo n.º 14
0
        public void CanDelete(string OrderDate, string NameInput, string StateInput, string ProductInput, decimal AreaInput, bool success)
        {
            OrderManager manager   = OrderManagerFactory.Create();
            DateTime     orderDate = DateTime.Parse(OrderDate);

            PlaceNewOrderResponse response          = manager.NewOrder(orderDate, NameInput, StateInput, ProductInput, AreaInput);
            AllOrdersResponse     preDeleteResponse = manager.AllOrderLookup(orderDate);
            int placedCount = preDeleteResponse.ListOfOrders.Count;

            DeleteOrderResponse responseDelete     = manager.DeleteOrder(response.Order);
            AllOrdersResponse   postDeleteResponse = manager.AllOrderLookup(orderDate);
            int deleteCount = postDeleteResponse.ListOfOrders.Count;

            Assert.AreEqual(success, responseDelete.Success);
            Assert.AreEqual(deleteCount, (placedCount - 1));
        }
        public void Execute()
        {
            OrderManager        manager        = OrderManagerFactory.Create();
            OrderLookupWorkflow lookupWorkflow = new OrderLookupWorkflow();
            Order orderToDelete = lookupWorkflow.Execute(true);

            if (orderToDelete != null)
            {
                string deleteResponse;
                bool   validInput = false;
                do
                {
                    Console.WriteLine("Is this the order you wish to permenantly delete?\nEnter Y/N");
                    deleteResponse = Console.ReadLine().ToLower();

                    if (deleteResponse == "y" || deleteResponse == "n")
                    {
                        validInput = true;
                    }
                } while (!validInput);

                Console.Clear();

                DeleteOrderResponse response = null;
                if (deleteResponse == "y")
                {
                    response = manager.DeleteOrder(orderToDelete);

                    if (response.Success)
                    {
                        Console.WriteLine("Your order was successfully deleted\nPress any key to continue...");
                        Console.ReadKey();
                    }
                    else if (!response.Success)
                    {
                        Console.WriteLine("An error occurred");
                        Console.WriteLine(response.Message);
                    }
                }
                else
                {
                    Console.WriteLine("\nDelete Order Request Cancelled\nPress any key to continue");
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 16
0
        public DeleteOrderResponse DeleteOrder(string datestring, int orderNumber)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            try
            {
                _orderRepository.Delete(datestring, orderNumber);
            }
            catch (Exception e)
            {
                response.Success = false;
                response.Message = e.Message;
            }
            response.Success     = true;
            response.OrderNumber = orderNumber;
            return(response);
        }
        internal static void Execute()
        {
            Console.Clear();

            OrderManager manager = OrderManagerFactory.Create();

            var userDateTimeInPut            = ConsoleIO.GetFutureDateTime("Please enter a date. EX: MM/DD/YYYY ");
            OrderDateLookupResponse response = manager.OrderLookupDate(userDateTimeInPut);

            if (response.Success)
            {
                foreach (var order in response.ListOfOrders)
                {
                    Console.WriteLine($"Order Number: {order.OrderNumber}, Customer Name: {order.CustomerName}, State {order.State}, Tax Rate: {order.TaxRate}, Area: {order.Area}, Cost Per Square Foot: {order.CostPerSquareFoot}, Labor Cost Per Square Foot: {order.LaborCostPerSquareFoot}, Material Cost: {order.MaterialCost}, Labor Cost: {order.LaborCost}, Tax Total: {order.TotalTax}, Total Cost: {order.TotalCost}");
                }

                int number = ConsoleIO.GetOrderNumber("Which Order number would you like to remove? Enter the Order number you want to remove. ");

                if (ConsoleIO.GetYesNoAnswerFromUser($"Are you sure you want to remove this file?") == "Y")
                {
                    DeleteOrderResponse deleteResponse = manager.DeleteOrder(userDateTimeInPut, number);
                    if (deleteResponse.Success)
                    {
                        Console.WriteLine("The Order was successfully deleted.");
                        Console.WriteLine("Press any key to continue...");
                    }
                    else
                    {
                        Console.WriteLine("An error occurred.");
                        Console.WriteLine(deleteResponse.Message);
                    }
                }
                else
                {
                    Console.WriteLine("A delete order was cancelled. Press any key to continue.");
                }
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("An error has occurred");
                Console.WriteLine(response.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Deletes the order. --sunny
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public bool DeleteOrder(int id)
        {
            DeleteOrderRequest request = new DeleteOrderRequest()
            {
                OrderId = id
            };
            DeleteOrderResponse response = MyChannelFactory.CreateChannel().DeleteOrder(request);

            if (response.IsFailed == true)
            {
                response = myChannelFactory.CreateChannel().DeleteOrder(request);
                if (response.IsFailed == true)
                {
                    throw (new Exception(response.Message));
                }
            }
            return(!response.IsFailed);
        }
Exemplo n.º 19
0
        public DeleteOrderResponse DeleteOrder(Order order)

        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            response.Order = order;

            if (response.Order == null)
            {
                response.Success = false;
                response.Message = $"{order} is not a valid order.";
            }
            else
            {
                response.Success = true;
                response.Success = _orderRepo.DeleteOrder(order);
            }
            return(response);
        }
Exemplo n.º 20
0
        public DeleteOrderResponse DeleteOrder(string date, int orderNumber)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();


            if (!_orderRepository.DeleteOrder(date, orderNumber))
            {
                response.Success = false;
                response.Message = $"Failed to remove {orderNumber} on {date}";
            }
            else
            {
                response.Success = true;
            }



            return(response);
        }
Exemplo n.º 21
0
        public DeleteOrderResponse DeleteOrder(Order order)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            List <Order> orders = _orderRepository.List(order.OrderDate);

            _orderRepository.DeleteOrder(order, orders);

            if (orders.Any(o => o == order))
            {
                response.Success = false;
                response.Message = $"Failed to delete Order: {order.OrderNumber} - {order.OrderDate:MM/dd/yyyy}";
            }
            else
            {
                response.Success = true;
            }

            return(response);
        }
Exemplo n.º 22
0
        public DeleteOrderResponse DeleteOrder(Order orderToDelete)
        {
            DeleteOrderResponse response = new DeleteOrderResponse();

            _orderRepo.DeleteOrder(orderToDelete);

            OrderLookupResponse deleteCheck = OrderLookup(orderToDelete.OrderNumber, orderToDelete.OrderDate);

            if (!deleteCheck.Success)
            {
                response.Success = true;
            }
            else
            {
                response.Success = false;
                response.Message = "The order was not successfully deleted";
            }

            return(response);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Deletes the order. --sunny
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public bool DeleteOrder(int id)
        {
            DeleteOrderRequest request = new DeleteOrderRequest()
            {
                OrderId = id
            };
            DeleteOrderResponse response = MyChannelFactory.CreateChannel().DeleteOrder(request);

            if (response.IsFailed == true)
            {
                response = myChannelFactory.CreateChannel().DeleteOrder(request);
                if (response.IsFailed == true)
                {
                    ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
                    log.Error("error", new Exception(response.Message));
                    log.Fatal("fatal", new Exception(response.Message));
                    throw (new Exception(response.Message));
                }
            }
            return(!response.IsFailed);
        }
Exemplo n.º 24
0
        public void Execute()
        {
            Console.Clear();
            ConsoleIO.HeadingLable("Delete an Order");
            int      orderNumber = ConsoleIO.GetIntInputFromUser("Order Number: ");
            DateTime orderDate   = ConsoleIO.GetDateFromUser("Order Date (MM/DD/YYYY): ", true);

            OrderManager        orderManager   = OrderManagerFactory.Create();
            OrderLookupResponse lookupResponse = orderManager.LookupOrder(orderNumber, orderDate);

            if (lookupResponse.Success)
            {
                ConsoleIO.DisplayOrderInformation(lookupResponse.Order, true);
                bool deleteIt = ConsoleIO.GetYesNoAnswerFromUser("Are you sure you want to delete this order?");
                if (deleteIt)
                {
                    DeleteOrderResponse deleteResponse = orderManager.DeleteOrder(lookupResponse.Order);
                    if (deleteResponse.Success)
                    {
                        ConsoleIO.YellowMessage("Order Deleted!");
                    }
                    else
                    {
                        ConsoleIO.RedMessage($"An Error Occured: {deleteResponse.Message}");
                    }
                }
                else
                {
                    ConsoleIO.RedMessage("Delete order cancelled.");
                }
            }
            else
            {
                ConsoleIO.RedMessage($"An Error Occured: {lookupResponse.Message}");
            }

            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
Exemplo n.º 25
0
        public EditExistingOrderResponse EditOrder(Order editedOrder)
        {
            EditExistingOrderResponse response = new EditExistingOrderResponse();

            bool failState = false;

            if (!failState)
            {
                DeleteOrderResponse deleteResponse = DeleteOrder(editedOrder.OrderDate, editedOrder.OrderNumber);

                if (deleteResponse.Success)
                {
                    response.Order = _orderRepo.EditOrder(editedOrder);
                }
                else
                {
                    failState        = true;
                    response.Message = "Failed to delete previous order";
                }
            }

            if (failState)
            {
                response.Success = false;
            }
            else if (response.Order == null)
            {
                response.Success = false;
                response.Message = "An error occurred while submitting the order";
            }
            else
            {
                response.Success = true;
            }

            return(response);
        }
Exemplo n.º 26
0
        public void DeleteOrderResponseTest(string datestring, int orderNumber, bool expectedResult)
        {
            DeleteOrderResponse response = manager.DeleteOrder(datestring, orderNumber);

            Assert.AreEqual(expectedResult, response.Success);
        }
Exemplo n.º 27
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            Console.WriteLine("Remove an order");
            Console.WriteLine("------------------------");
            bool     isValidDate = false;
            DateTime orderDate   = new DateTime();
            string   date1       = "";

            while (isValidDate == false)
            {
                date1 = io.GetDateFromUser("Please provide a date");

                orderDate = DateTime.ParseExact(date1, "MMddyyyy", CultureInfo.GetCultureInfo("en-us"));

                if (orderDate <= DateTime.Today)
                {
                    Console.WriteLine("Date must be later than today");
                }
                else
                {
                    isValidDate = true;
                }
            }

            DisplayOrderResponse response = manager.LoadOrders(date1);

            foreach (FlooringOrder order in response.Orders)
            {
                io.DisplayOrderDetails(order);
            }

            int  ordernumber   = -1;
            bool isValidNumber = false;

            while (isValidNumber == false)
            {
                string orderstring = io.GetStringFromUser("Please enter an order number.");
                if (!int.TryParse(orderstring, out ordernumber))
                {
                    Console.WriteLine("This did not work, please enter a number");
                }
                else
                {
                    foreach (var item in response.Orders)
                    {
                        if (item.OrderNumber == ordernumber)
                        {
                            newOrder = item;
                        }
                    }
                    isValidNumber = true;
                }
            }

            //if one order = delete entire file
            //if theres more than one order in date, remove the order number from list -> remove with LINQ
            //save list back to file for that date

            io.DisplayOrderDetails(newOrder);
            bool isSave = false;

            while (isSave == false)
            {
                string place = PromptUser("Are you entireley sure that you want to remove this order? Choose yes or no.");
                if (place.ToLower() == "yes")
                {
                    DeleteOrderResponse deleteResponse = manager.DeleteOrder(date1, newOrder.OrderNumber);
                    isSave = true;
                    // save final to file with approps date
                }
                else if (place.ToLower() == "no")
                {
                    isSave = true;
                }
                else
                {
                    Console.WriteLine("Please enter yes or no");
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }
Exemplo n.º 28
0
 public void TestDeleteOrder()
 {
     DeleteOrderResponse response = new DeleteOrderResponse();
     Expect.Once.On(service).Method("DeleteOrder").Will(Return.Value(response));
     serviceFacade.DeleteOrder(1);
 }
Exemplo n.º 29
0
        public DeleteOrderResponse DeleteOrder(Order order)
        {
            DeleteOrderResponse response = _serv.Delete(order);

            return(response);
        }