public IActionResult UpdateOrder(int id) { OrderMediator.MarkAsComplete(orders.Single (order => order.Id == id)); return(View("Orders", orders)); }
private void searchOrderBtn_Click(object sender, RoutedEventArgs e) { string seatIDStr = seatIDTxt.Text.Trim(); bool success = int.TryParse(seatIDStr, out seatID); if (!success) { errorLbl.Text = "Seat ID is not a number"; } else { errorLbl.Text = ""; OrderMediator mediator = new OrderMediator(); Order customerOrder = mediator.getOrderBySeat(seatID); if (customerOrder == null) { errorLbl.Text = "Seat is empty!"; return; } var orderDetail = mediator.getAllOrderDetail(customerOrder.orderID); orderDetailView.ItemsSource = orderDetail; totalPrice = mediator.getTotalPrice(customerOrder.orderID); tax = ((totalPrice * 10) / 100); totalPriceTxt.Text = "Total Price = \t\tRp. " + totalPrice.ToString(); taxTxt.Text = "Tax = \t\t\tRp. " + tax.ToString(); totalPriceAfterTaxTxt.Text = "Total Price After Tax = \tRp. " + (totalPrice + tax).ToString(); } }
public CommandFactory(ICommandQueue incomingQueue, ICommandQueue outgoingQuue, OrderMediator orderMediator, SessionMediator sessionMediator) { IncomingQueue = incomingQueue; OutgoingQueue = outgoingQuue; _orderMediator = orderMediator; _sessionMediator = sessionMediator; }
public IActionResult DisplayOrderCheckout(string email, string comment) { OrderMediator.CurrentOrder.Email = email; OrderMediator.CurrentOrder.Comment = comment; OrderMediator.UploadCurrentOrder(); var session = GetStripeSession(); return(View(new OrderCheckoutModel(OrderMediator.CurrentOrder, session.Id))); }
public Order createNewOrder(int seatID) { OrderMediator mediator = new OrderMediator(); Order order = new Order(); order.orderID = mediator.getLastID() + 1; order.seatID = seatID; order.status = "Waiting"; return(order); }
private void checkOutButton_Click(object sender, RoutedEventArgs e) { string paymentStr = paymentTxt.Text.Trim(); int payment; bool success = int.TryParse(paymentStr, out payment); if (!success) { errorLbl.Text = "Payment must be a number!"; } else if (totalPrice == 0 || tax == 0) { errorLbl.Text = "Please input Seat ID!"; } else { int change = (totalPrice + tax) - payment; if (change > 0) { errorLbl.Text = "Payment is not enough!"; } else if (change <= 0) { SeatMediator mediator = new SeatMediator(); OrderMediator omediator = new OrderMediator(); Order customerOrder = omediator.getOrderBySeat(seatID); changeTxt.Text = "Change = \t\tRp. " + Math.Abs(change).ToString(); RestaurantTransactionMediator tmediator = new RestaurantTransactionMediator(); RestaurantTransactionFactory tfactory = new RestaurantTransactionFactory(); RestaurantTransaction transaction = tmediator.addRestaurantTransaction(tfactory.createNewRestaurantTransaction(seatID)); if (tmediator.addDetailRestaurantTransaction(transaction.transactionID, customerOrder.orderID) == null) { MessageBox.Show("Checkout failed!"); } else { MessageBox.Show("Checkout success!"); } //update seat dan ordernya Seat customerSeat = mediator.getSeat(seatID); customerSeat.status = "Available"; customerSeat = mediator.updateSeat(seatID, customerSeat); customerOrder.status = "Finished"; customerOrder = omediator.updateOrder(customerOrder.orderID, customerOrder); } } }
public AddOrder(CommandFactory commandFactory, IFixMessageGenerator fixMessageGenerator, OrderMediator orderMediator, FixSessionID sessionID, OrderData orderData, string execID) { _commandFactory = commandFactory; _fixMessageGenerator = fixMessageGenerator; _orderMediator = orderMediator; _sessionID = sessionID; _orderData = orderData; _execID = execID; }
public IActionResult Orders(string username, string password) { //do username password check here if (username != null && password != null) { if (username == admin.Username && password == admin.Password) { orders = OrderMediator.GetAllValidOrders(); return(View(orders)); } } return(View("Login")); }
public CancelOrder(CommandFactory commandFactory, IFixMessageGenerator messageGenerator, OrderMediator orderMediator, FixSessionID sessionID, long orderID, string clOrdID, string origClOrdID, string execID) { _commandFactory = commandFactory; _messageGenerator = messageGenerator; _orderMediator = orderMediator; _sessionID = sessionID; _orderID = orderID; _clOrdID = clOrdID; _origClOrdID = origClOrdID; _execID = execID; }
public IActionResult Success() { var order = OrderMediator.CurrentOrder; OrderMediator.MarkAsPaymentReceived(order); var mailService = new EmailService(); try { mailService.SendConfirmationMessage(order.Email, order.Id); } catch (Exception ee) { mailService.Log("Did not send mail on order_Id: " + order.Id + "\n" + "error message; + " + ee.Message); } return(View()); }
public void CancellingAnOrderWhenYouAreTheOwningSessionSucceeds() { var mockRepository = new Mock <IOrderRepository>(); var o = DefaultOrder(1); mockRepository.Setup(r => r.AddOrder(o.ID, o.Contract, o.OrderType, o.MarketSide, o.Price, o.Quantity, o.ClOrdID, o.Account)) .Returns(o); mockRepository.Setup(r => r.DeleteOrder(o.ID)).Returns(o); Action <OrderMatch, FixSessionID> emptyMatchCallback = (m, s) => { }; var mediator = new OrderMediator(mockRepository.Object, emptyMatchCallback); var fakeSessionId = new FixSessionID(); var addedOrder = mediator.AddOrder(fakeSessionId, o.OrderType, o.Contract.Symbol, o.MarketSide, o.ClOrdID, o.Account, o.Quantity, o.Price); Assert.AreEqual(o.ID, addedOrder.ID); Assert.AreEqual(o.ClOrdID, addedOrder.ClOrdID); var cancelledOrder = mediator.CancelOrder(addedOrder.ID, fakeSessionId); Assert.IsNotNull(cancelledOrder, "Cancelled order should not be null"); mockRepository.Verify(r => r.DeleteOrder(o.ID), Times.Once()); Assert.AreEqual(o.ID, cancelledOrder.ID); Assert.AreEqual(o.ClOrdID, cancelledOrder.ClOrdID); }
private void submitBtn_Click(object sender, RoutedEventArgs e) { string orderIDStr = orderIDTxt.Text.Trim(); int orderID; bool success = int.TryParse(orderIDStr, out orderID); if (!success) { errorLbl.Text = "Order ID is not a number"; } else if (statusComboBox.SelectedItem == null) { errorLbl.Text = "Please input all field"; } else { OrderMediator mediator = new OrderMediator(); string status = (string)((ComboBoxItem)statusComboBox.SelectedValue).Content; Order order = mediator.getOrder(orderID); if (order == null) { errorLbl.Text = "Order doesn't exist"; } else { order.status = status; order = mediator.updateOrder(orderID, order); if (order == null) { MessageBox.Show("Change status failed!"); } else { MessageBox.Show("Change Status success"); } refresh(); } } }
public ActionResult Review(PaymentVM model) { var oMediator = new OrderMediator(); var tMediator = new TicketMediator(); if (model.SameAsBilling) { model.ShippingAddress.Address1 = model.BillingAddress.Address1; model.ShippingAddress.City = model.BillingAddress.City; model.ShippingAddress.State = model.BillingAddress.State; model.ShippingAddress.Zip = model.BillingAddress.Zip; } var success = oMediator.CreateOrder(model); if (success) { //tMediator.ClearCart(); return(Redirect("/checkout/confirmation")); } return(View("~/Views/Checkout/Review.cshtml", model)); }
private void orderIDTxt_TextChanged(object sender, TextChangedEventArgs e) { string orderIDStr = orderIDTxt.Text.Trim(); int orderID; bool success = int.TryParse(orderIDStr, out orderID); if (!success && orderIDTxt.Text != "") { errorLbl.Text = "Order ID is not a number"; } else { errorLbl.Text = ""; OrderMediator mediator = new OrderMediator(); if (mediator.getOrder(orderID) == null) { orderDetailView.ItemsSource = null; return; } orderDetailView.ItemsSource = mediator.getAllOrderDetail(orderID); } }
public void CancellingAnOrderWhenYouAreNotTheOwningSessionFails() { var mockRepository = new Mock <IOrderRepository>(); var o = DefaultOrder(1); mockRepository.Setup(r => r.AddOrder(o.ID, o.Contract, o.OrderType, o.MarketSide, o.Price, o.Quantity, o.ClOrdID, o.Account)) .Returns(o); Action <OrderMatch, FixSessionID> emptyMatchCallback = (m, s) => { }; var mediator = new OrderMediator(mockRepository.Object, emptyMatchCallback); var fakeSessionId1 = new FixSessionID(); var fakeSessionId2 = new FixSessionID(); Assert.AreNotEqual(fakeSessionId1, fakeSessionId2); var addedOrder = mediator.AddOrder(fakeSessionId1, o.OrderType, o.Contract.Symbol, o.MarketSide, o.ClOrdID, o.Account, o.Quantity, o.Price); Assert.Throws <FixATServerException>( () => mediator.CancelOrder(addedOrder.ID, fakeSessionId2)); mockRepository.Verify(r => r.DeleteOrder(o.ID), Times.Never()); }
private void refresh() { OrderMediator mediator = new OrderMediator(); orderView.ItemsSource = mediator.getAllOrder(); }
public void Run() { var pizzaFactory = new PizzaFactory(_pizzaBuildState, _orderConstructor); var margarita = pizzaFactory.MakePizza(Enum_Menu.Pepperoni, Enum_PizzaType.GlutenFree); var order = new NormalOrder(5, new Pizza { Price = 12 }); var makeOrder = order.MakeOrder(); var calculateCost = order.CalculateCost(); var removePizzaFromOrder = new RemovePizzaFromOrder(order, 2); var updateOrderAfterRemovePizza = removePizzaFromOrder.UpdateOrder(); var calculateCostAfterRemovePizza = removePizzaFromOrder.CalculateCost(); var addPizzaToOrder = new AddPizzaToOrder(removePizzaFromOrder, 7, new Pizza { Price = 22 }); var updateOrdeAfterAddPizzaToOrder = addPizzaToOrder.UpdateOrder(); var calculateCostAfterAddPizzaToOrder = addPizzaToOrder.CalculateCost(); var custom = pizzaFactory.MakePizza(Enum_Menu.CustomPizza, Enum_PizzaType.GlutenFree); var customPizza = new CustomPizzaFluentBuilder(custom) .AddDough("Custom Dough") .AddSauce("Custom Sauce") .SetCheese("Custom Cheese") .Build(); int pizzaCount = 3; var pizzaList = _clone.GetPizzaCloneList(margarita.Clone(), pizzaCount); var restaurantFacade = new RestaurantFacade(); restaurantFacade.GetOrder(Enum_OrderType.Drinks); var traineeServer = new TraineeServer(new Server()); traineeServer.MakeOrder(new Pizza { Count = 3 }); var mediator = new OrderMediator(); var pizzaType = Enum_Menu.Pepperoni; var pizza = Enum_PizzaType.Normal; var webPage = new WebPage(mediator); var restaurantService = new RestaurantService(mediator, pizzaType, pizza, _pizzaBuildState, _orderConstructor); mediator.Restaurant = restaurantService; mediator.WebPage = webPage; var orderManager = new OrderManager(); var orderManagerAdapter = new OrderMenagerAdapter(orderManager); var orderFromAdapter = orderManagerAdapter.OrderManager; PizzaProcessLogger.LogsList.Clear(); var log = PizzaProcessLogger.LogsList; Build build = new Build(string.Empty); PizzaBuilderManager pizzaBuilderManager = new PizzaBuilderManager(build); Action saveCurrentBuild = () => pizzaBuilderManager.SaveCurrentBuild(); webPage.Send($"Poproszę pizze: {pizzaType.ToString()}"); restaurantService.Send("Zamówienie zostało przekazane"); webPage.Send("Czy mogę zobaczyc proces tworzenia pizzy"); restaurantService.Send("Tak, proszę bardzo"); for (int i = 0; i < PizzaProcessLogger.LogsList.Count; i++) { build.SetState(log[i]); pizzaBuilderManager.SaveCurrentBuild(); saveCurrentBuild.Invoke(); Console.WriteLine(log[i]); } webPage.Send("Chciałbym pizze bez ostatniego składnika, czy to możliwe?"); restaurantService.Send("Tak, oczywiście! bardzo proszę"); pizzaBuilderManager.Undo(pizzaType.ToString()); webPage.Send("Dziękuję"); }
private void submitBtn_Click(object sender, RoutedEventArgs e) { string seatIDStr = seatIDTxt.Text.Trim(); string foodIDStr = foodIDTxt.Text.Trim(); string quantityStr = quantityTxt.Text.Trim(); int seatID, foodID, quantity; bool success = int.TryParse(seatIDStr, out seatID); bool success2 = int.TryParse(foodIDStr, out foodID); bool success3 = int.TryParse(quantityStr, out quantity); if (!success) { errorLbl.Text = "Seat ID must be a number"; } else if (!success2) { errorLbl.Text = "Food ID must be a number"; } else if (!success3) { errorLbl.Text = "Quantity must be a number"; } else { OrderMediator mediator = new OrderMediator(); SeatMediator smediator = new SeatMediator(); FoodMediator fmediator = new FoodMediator(); OrderFactory factory = new OrderFactory(); Order order = mediator.getOrderBySeat(seatID); Seat seat = smediator.getSeat(seatID); Food food = fmediator.getFood(foodID); if (seat == null) { errorLbl.Text = "Seat doesn't exist"; return; } if (food == null) { errorLbl.Text = "Food doesn't exist"; return; } if (order == null) { mediator.addOrder(factory.createNewOrder(seatID)); seat.status = "Unavailable"; seat = smediator.updateSeat(seatID, seat); } order = mediator.getOrderBySeat(seatID); OrderDetail existingOrder = mediator.getOrderDetail(order.orderID, foodID); OrderDetail orderDetail; if (existingOrder == null) { orderDetail = mediator.addOrderDetail(factory.createNewOrderDetail(order.orderID, foodID, quantity)); } else { existingOrder.quantity += quantity; orderDetail = mediator.updateOrderDetail(order.orderID, existingOrder); } if (orderDetail == null) { MessageBox.Show("Input order failed!"); } else { MessageBox.Show("Input order success!"); } } }
public MatchOrders(OrderMediator orderMediator, string symbol) { _orderMediator = orderMediator; _symbol = symbol; }