public ChangeMessageStub WithOrderChange(OrderChange oc) { _change.OrderChanges ??= new List <OrderChange>(); _change.MarketChanges = null; _change.Operation = "ocm"; _change.OrderChanges.Add(oc); return(this); }
public async Task <IActionResult> DeleteConfirmed(int id) { var order = await _context.Orders .Include(o => o.User) .Include(o => o.Customer) .Include(o => o.DetailOrders) .ThenInclude(i => i.Product) .FirstOrDefaultAsync(o => o.ID == id); try { foreach (var i in order.DetailOrders) { i.Product.SoLuong += i.SoLuong; _context.Products.Update(i.Product); } _context.Orders.Remove(order); var user = await _userManager.GetUserAsync(User); var orderChange = new OrderChange { ThoiGian = DateTime.Now, UserName = user.UserName, HanhDong = "Xóa", OrderID = order.ID }; _context.OrderChanges.Add(orderChange); await _context.SaveChangesAsync(); TempData["messageSuccess"] = $"Đơn hàng \"{order.ID}\" đã xóa"; return(RedirectToAction("Index")); } catch { var model = new OrderViewModel { ID = order.ID, ThoiGianTao = order.ThoiGianTao, UserName = order.User.Ten, CustomerName = order.Customer.Ten }; foreach (var item in order.DetailOrders) { var itemVM = new DetailOrder { Gia = item.Gia, SoLuong = item.SoLuong, Product = item.Product }; model.DetailOrders.Add(itemVM); } ModelState.AddModelError(string.Empty, "Đã xảy ra lỗi trong quá trình xóa đơn hàng, vui lòng thử lại vào thời gian khác!"); return(View(model)); } }
private void OnOrderChange(OrderChange orderChange) { if (orderChange is null) { return; } if (orderChange.MarketId != MarketId) { return; } orderChange.OrderRunnerChanges.ForEach(ProcessOrderRunnerChange); UpdateRunnerProfits(); }
public bool Visit(OrderChange msg) { Condition.Requires(msg.OrderId, "msg.OrderId").IsNotNull(); Order order; if (!_manager._openOrders.TryGetValue(msg.OrderId, out order)) { return(false); } Condition.Requires(msg.NewSize, "msg.NewSize").IsNotNull(); order.Unfilled = msg.NewSize.Value; PublishUpdate(msg, order, fill: null, finished: false); return(false); }
public SubscriptionSpy WithOrderChange(OrderChange orderChange) { var change = new ChangeMessage { Operation = "orc", ChangeType = "oc", OrderChanges = new List <OrderChange> { orderChange }, PublishTime = PublishTime, }; Messages.Add(change); return(this); }
public GridOrdersRepository(int orderCount, OrderChange orderChange) : base() { this.orderCount = orderCount; this.now = DateTime.Now; this.random = new Random((int)this.now.Ticks); this.availableCommodities = new List <Commodity>(); GenerateCustomers(); GenerateCommodities(); int percent = orderCount / 100; for (int i = 0; i < orderCount; i++) { Orders.Add(GenerateOrder(i)); if (orderChange != null && i % percent == 0) { Action action = new Action(() => { orderChange(i / percent); }); Device.BeginInvokeOnMainThread(action); } } }
/// <summary> /// Instantiate a new instance of this class. /// </summary> /// <param name="data">The order change event data.</param> public OrderChangeEventArgs(OrderChange data) { EventData = data; Type = data.Type; }
public bool ProcessIncomingConfirmation(ConfirmationFile confirmation) { if (String.IsNullOrEmpty(confirmation.Header.ConfirmationNumber)) { throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Confirmation Number is Required", new Exception()); } ; if (String.IsNullOrEmpty(confirmation.Header.InvoiceNumber)) { throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Invoice Number is Required", new Exception()); } ; if (confirmation.Header.ConfirmationStatus == null) { throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Confirmation Status is Required", new Exception()); } ; var poNum = confirmation.Header.ConfirmationNumber; PurchaseOrder po = GetCsPurchaseOrderByNumber(poNum); NewRelic.Api.Agent.NewRelic.AddCustomParameter("ConfirmationNumber", confirmation.Header.ConfirmationNumber); NewRelic.Api.Agent.NewRelic.AddCustomParameter("CustomerNumber", confirmation.Header.CustomerNumber); NewRelic.Api.Agent.NewRelic.AddCustomParameter("Branch", confirmation.Header.Branch); NewRelic.Api.Agent.NewRelic.AddCustomParameter("ItemCount", confirmation.Detail.Count()); if (po == null) { _log.WriteWarningLog("Could not find PO for confirmation number: {ConfirmationNumber}, Line: 399, Method: ProcessIncomingConfirmation".InjectSingleValue("ConfirmationNumber", poNum)); } else { // make sure that there are items to process if (po.LineItemCount == 0 || po.OrderForms[0].LineItems.Count == 0) { throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Purchase order has no line items", new Exception()); } // need to save away pre and post status info, then if different, add something to the messaging LineItem[] currLineItems = new LineItem[po.LineItemCount]; LineItem[] origLineItems = new LineItem[po.LineItemCount]; po.OrderForms[0].LineItems.CopyTo(currLineItems, 0); po.OrderForms[0].LineItems.CopyTo(origLineItems, 0); string originalStatus = po.Status; if (confirmation.Header.ConfirmationStatus.Equals(Constants.CONFIRMATION_HEADER_REJECTED_CODE, StringComparison.InvariantCultureIgnoreCase)) { // Update line item status' to rejected foreach (var item in currLineItems) { item["MainFrameStatus"] = "Rejected"; } } else { SetCsLineInfo(currLineItems, confirmation); } SetCsHeaderInfo(confirmation, po, currLineItems); string logMessage = string.Format("Updating purchase order status to '{0}' for tracking number {1}, confirmation number {2}, and invoice number {3}.", po.Status, po.TrackingNumber, confirmation.Header.ConfirmationNumber, confirmation.Header.InvoiceNumber); _log.WriteInformationLog(logMessage); po.Save(); // use internal messaging logic to put order up message on the queue OrderChange orderChange = BuildOrderChanges(po, currLineItems, origLineItems, originalStatus, confirmation.Header.SpecialInstructions, confirmation.Header.ShipDate); if (orderChange.OriginalStatus != orderChange.CurrentStatus || orderChange.ItemChanges.Count > 0) { OrderConfirmationNotification orderConfNotification = new OrderConfirmationNotification(); orderConfNotification.OrderChange = orderChange; orderConfNotification.OrderNumber = (string)po["OrderNumber"]; orderConfNotification.CustomerNumber = (string)po["CustomerId"]; orderConfNotification.BranchId = (string)po["BranchId"]; orderConfNotification.InvoiceNumber = confirmation.Header.InvoiceNumber; genericeQueueRepository.PublishToDirectedExchange(orderConfNotification.ToJson(), Configuration.RabbitMQNotificationServer, Configuration.RabbitMQNotificationUserNamePublisher, Configuration.RabbitMQNotificationUserPasswordPublisher, Configuration.RabbitMQVHostNotification, Configuration.RabbitMQExchangeNotificationV2, Constants.RABBITMQ_NOTIFICATION_ORDERCONFIRMATION_ROUTEKEY); } } return(true); }
void ReorderWidgets(object sender, OrderChange direction) { IAppConfigWidget widget = sender as IAppConfigWidget; if (widget == null || direction == OrderChange.Undefined) { return; } int widgetPosition = _widgets.IndexOf (widget); _widgets.Remove (widget); switch (direction) { case OrderChange.Up: widgetPosition -= 1; break; case OrderChange.Down: widgetPosition += 1; break; } _widgets.Insert (widgetPosition, widget); _configWindow.ClearWidgets (); foreach (IAppConfigWidget newWidget in _widgets) { _configWindow.AddAppConfigWidget (newWidget); } UpdateWidgetButtons (); }
public async Task <IActionResult> Create([Bind("CustomerID")] OrderCreateViewModel model) { var order = SessionHelper .GetObjectFormJson <OrderCreateViewModel>(HttpContext.Session, "order"); if (order.DetailOrders.Count == 0) { ModelState.AddModelError("", "Vui lòng thêm sản phẩm vào đơn hàng!"); } if (ModelState.IsValid) { var customer = await _context.Customers .AsNoTracking() .FirstOrDefaultAsync(c => c.ID == model.CustomerID); if (customer == null) { return(NotFound()); } var user = await _userManager.GetUserAsync(User); if (user == null) { RedirectToAction("Login", "Users"); } var orderAdd = new Order { ThoiGianTao = order.ThoiGianTao, UserID = user.Id, CustomerID = customer.ID }; _context.Orders.Add(orderAdd); await _context.SaveChangesAsync(); foreach (var i in order.DetailOrders) { var detailOrder = new DetailOrder { Gia = i.Gia, SoLuong = i.SoLuongBan, OrderID = orderAdd.ID, ProductID = i.ProductID }; _context.DetailOrders.Add(detailOrder); var productEdit = await _context.Products .FirstOrDefaultAsync(p => p.ID == i.ProductID); productEdit.SoLuong -= i.SoLuongBan; _context.Products.Update(productEdit); } var orderChange = new OrderChange { ThoiGian = orderAdd.ThoiGianTao, UserName = user.UserName, HanhDong = "Thêm", OrderID = orderAdd.ID }; _context.OrderChanges.Add(orderChange); await _context.SaveChangesAsync(); TempData["messageSuccess"] = $"Đơn hàng \"{orderAdd.ID}\" đã thêm"; HttpContext.Session.Clear(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(_context.Customers, "ID", "Ten", model.CustomerID); ViewBag.Order = order; return(View(model)); }