public void GetContents_produces_all_orders() { var orders = new Orders(); var order = new Order(1234); order.Add(new Product(4321, "T-Shirt", ProductSize.Medium, "21.00")); order.Add(new Product(6789, "Socks", ProductSize.Medium, "8.00")); orders.Add(order); var ordersWriter = new OrdersWriter(orders); var expectedOrder = "<orders>" + "<order id='1234'>" + "<product id='4321' color='red' size='medium'>" + "<price currency='USD'>" + "21.00" + "</price>" + "T-Shirt" + "</product>" + "<product id='6789' color='red' size='medium'>" + "<price currency='USD'>" + "8.00" + "</price>" + "Socks" + "</product>" + "</order>" + "</orders>"; Assert.Equal(expectedOrder, ordersWriter.GetContents()); }
public Order(ShoppingCart shoppingCart) : this() { if (!shoppingCart.ShoppingCartItems.Any()) { throw new InvalidOperationException("Vui lòng thêm một hoặc nhiều mặt hàng vào giỏ hàng của bạn trước khi đặt hàng."); } foreach (ShoppingCartItem cart in shoppingCart.ShoppingCartItems) { for (int i = 1; i <= cart.Count; i++) { cart.Items.QuantityOrdered++; string qrcode = String.Format(Guid.NewGuid().ToString() + DateTime.Now.ToString("yyyyMMddhhmmssffffff")); Orders.Add(new OrderItem { Items = cart.Items, Count = 1, Price = cart.Price, Validity = Validity.Invalid, CreationDate = DateTime.Today, Seller = cart.Items.Seller, QRCode = qrcode }); } } }
public ApplicationViewModel() { db = new PhotoStudioContext(); db.Orders.Load(); db.Clients.Load(); db.Services.Load(); db.SaveChanges(); foreach (Order order in db.Orders.Local.ToList()) { Orders.Add(order); } foreach (Client client in db.Clients.Local.ToList()) { Clients.Add(client); } foreach (Service service in db.Services.Local.ToList()) { Services.Add(service); } }
public void Ask_PartialExecutes_AginstUser1Bid_ButAskSharesIsGreaterThanBidShares() { // Arrange. var existingBidOrder = new Order { Id = 100, Shares = 100, Subscription = new Subscription { Owned = 0, UserId = _userId1 } }; var existingLimit = Limits.First(); existingLimit.BidHead = existingBidOrder; existingBidOrder.ParentLimit = existingLimit; Limits.Add(existingLimit); Orders.Add(existingBidOrder.Id, existingBidOrder); Subscriptions.Add(existingBidOrder.Subscription.UserId, existingBidOrder.Subscription); var existingSellerSubscription = new Subscription { Owned = 500, UserId = _userId2 }; Subscriptions.Add(existingSellerSubscription.UserId, existingSellerSubscription); // Act. Ask(_userId2, 1, 200); // Assert. var existingBidOrder2 = new Order { Id = 100, Shares = 0, Subscription = new Subscription { Owned = 100, UserId = _userId1 } }; var existingLimit2 = new Limit { Price = 1 * ScaleFactor, BidHead = existingBidOrder2 }; existingBidOrder2.ParentLimit = existingLimit2; var existingSellerSubscription2 = new Subscription { Owned = 400, UserId = _userId2 }; var remainingSellersOrder = new Order { Id = 1, ParentLimit = existingLimit2, Shares = 100, Subscription = existingSellerSubscription2 }; existingLimit2.AskHead = remainingSellersOrder; Assert.AreEqual(1, Limits.Count); Assert.AreEqual(2, Orders.Count); Assert.AreEqual(2, Subscriptions.Count); CollectionAssert.AreEqual(new Limit[] { existingLimit2 }, Limits, _limitTestComparer); CollectionAssert.AreEqual(new Order[] { existingBidOrder2, remainingSellersOrder }, (ICollection)Orders.Values, _orderTestComparer); CollectionAssert.AreEqual(new Subscription[] { existingBidOrder2.Subscription, existingSellerSubscription2 }, (ICollection)Subscriptions.Values, _subscriptionTestComparer); }
public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList <TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer) { UnLock(); var order = new Order(); order.UpdateMenuItem(userName, menuItem, taxTemplates, portion, priceTag, 1); order.AccountTransactionTypeId = template.Id; order.WarehouseId = department.WarehouseId; order.DepartmentId = department.Id; TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts()); if (taxTemplates != null) { foreach (var taxTemplate in taxTemplates) { TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id, taxTemplate.AccountTransactionType, GetTicketAccounts()); } } order.UpdateProductTimer(timer); Orders.Add(order); return(order); }
public void Populate() { String sql = "select * from customer_order where paid_status like 'N' ; "; DataTable dt = DatabaseManager.Query(sql); //clear current Orders.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; Order ot = new Order(); ot.Id = int.Parse(dr["customer_order_id"].ToString()); ot.Cost = double.Parse(dr["total_cost"].ToString()); ot.CustomerId = int.Parse(dr["customer_id"].ToString()); if (dr["delivery_flag"].ToString() == "Y") { ot.Delivery = true; } else { ot.Delivery = false; } if (dr["paid_status"].ToString() == "Y") { ot.Paid = true; } else { ot.Paid = false; } ot.DateCreated = DateTime.Parse(dr["created_date"].ToString()); Orders.Add(ot); } }
public void OnNewAxe(FunnelUpdate axeUpdate) { if (axeUpdate.Stream == AxesStreamName && axeUpdate.Content != String.Empty) { var axeDict = (JObject)((JObject)axeUpdate.Content)["content"]; var axe = Axe.FromJObject(axeDict); var affectedOrders = SaveAxeAndReturnUpdatedOrders(axe); if (AxesUpdateHandler != null) { AxesUpdateHandler(axe); } if (OrdersUpdateHandler != null) { affectedOrders.ForEach(o => OrdersUpdateHandler(o)); } return; } if (axeUpdate.Stream == OrdersStreamName && axeUpdate.Content != String.Empty) { var orderDict = (JObject)axeUpdate.Content; var order = Order.FromJObject(orderDict); order.Axes = FindLatestAxes(order.ISIN); Orders.Add(order); if (OrdersAdditionHandler != null) { OrdersAdditionHandler(order); } } }
public void BuyAllFromCart() { var order = ShoppingCart.ToOrder(); ShoppingCart.Clear(); Orders.Add(order); }
/// <summary> /// Method fills the list dedicated to the coresponding window. /// </summary> public void FillList() { using (SqlConnection conn = new SqlConnection(ConnectionString)) { SqlCommand query = new SqlCommand("select * from tblOrder", conn); conn.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); if (Orders == null) Orders = new ObservableCollection<Order>(); foreach (DataRow row in dataTable.Rows) { Order o = new Order { Id = int.Parse(row[0].ToString()), User = new User(int.Parse(row[1].ToString())), OrderTimeStamp = (DateTime)row[2], Price = int.Parse(row[3].ToString()), Approved = (bool)row[4] }; Orders.Add(o); } } }
//saves the order whether new or editing //has error checking for required fields/lists (orderitems) private void SaveOrder() { Control errorControl; RevertPreviousErrorLabel(); _errProvider.Clear(); DateTime orderDate = _dpOrderDate.Value; DateTime deliveryDate = _dpDeliveryDate.Value; Client client = (Client)_cboOrderClient.SelectedItem; bool paid = _chkPaid.Checked; //decimal total = decimal.Parse(_txtTotalCost.Text); if (ValidInputs(out errorControl)) { //this way (and one if block later) //prevents weird nested if's from separating //edit and new Order currOrder = _editing ? (Order)_lstOrders.SelectedItem : new Order(); currOrder.OrderDate = orderDate; currOrder.DeliveryDate = deliveryDate; currOrder.OrderItems = GetOrderItems(); currOrder.Client = client; currOrder.Paid = paid; if (!_editing) { //adding to db first and the db method //returns the orderId to be updated //right away on client int orderNum = AddToDB(currOrder); if (orderNum > 0) { currOrder.OrderNumber = orderNum; AddOrderItemsToDB(currOrder); //db add Orders.Add(currOrder); } } else { UpdateDB(currOrder); //db update (editing) } ResetOrderList(); _lstOrders.SelectedItem = currOrder; SetItemSelectedState(); ResetErrors(); _editing = false; } else { SetRequiredError(errorControl); } }
public static void InsertOrder(int userId, Order order) { order.Id = ++orderId; Orders.Add(order); Users.Where(user => user.Id == userId).FirstOrDefault().Orders.Add(order); Console.WriteLine("Order successfully added!"); }
public virtual void OrderShip(ShipOrder order, bool append = false) { if (append) { // Can't append orders after a Patrol/Build! if (CurrentOrder != null && (CurrentOrder is PatrolOrder || CurrentOrder is BuildOrder || (Orders.Count > 0 && (Orders.Last() is PatrolOrder || Orders.Last() is BuildOrder)))) { return; } // Don't add an order that is already complete (dock replaced) if (!order.OrderComplete) { Orders.Add(order); } } else { if (CurrentOrder != null) { CurrentOrder.Cancel(this); } if (!order.OrderComplete) { Orders.Clear(); CurrentOrder = order; } } }
public void AddOrder(Order order) { if (order.Articles.Count > 0) { Orders.Add(order); } }
private void btnNewOrder_Click(object sender, RoutedEventArgs e) { // Create new order Order o = new Order(); o.Number = Order.Number + 1; // Add new order to the collection. Orders.Add(o); // Add default person. Person p = Persons[0]; Order.Recipient = p.Name; Order.Address = p.Address; Order.City = p.City; Order.Phone = p.Phone; Order.Date = DateTime.Now.ToShortDateString(); Order.Time = "10:00"; Order.OrderTotal = 0; OrderNumber = String.Format("Order {0:D3}", Order.Number); ProductsHeader = String.Format("Products list - {0}", OrderNumber); RefreshGrid(); tabControl.SelectedIndex = 0; MessageBox.Show(String.Format("The Order {0:D3} has been saved to XML and hided.\nNow, please add some products into Order {1:D3}.", o.Number - 1, o.Number)); }
protected OrderByBase(params OrderByModel <TEntity>[] args) { foreach (var item in args) { Orders.Add(item.OrderBy, item); } }
async Task ExecuteLoadOrdersCommand() { IsBusy = true; try { Orders.Clear(); //var myOrders = await OrderService.GetMyOrders(); //Pobieranie z serwisu nie działa var myOrders = new List <Order>() { new Order { Status = Enums.OrderStatus.Ongoing, Cost = 15.50, Type = Enums.CarType.Standard }, new Order { Status = Enums.OrderStatus.Finished, Cost = 55.40, Type = Enums.CarType.Seater7 } }; foreach (var myOrder in myOrders) { Orders.Add(myOrder); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void OrdersAdd(IEnumerable <Order> orders) { foreach (var order in orders) { Orders.Add(order); } }
private void LoadOrders() { var response = _igRestApiClient.workingOrdersV2().RunSync(); if (response && (response.Response != null) && (response.Response.workingOrders != null)) { Orders.Clear(); if (response.Response.workingOrders.Count != 0) { foreach (var order in response.Response.workingOrders) { var model = new OrderModel(); var market = GetInstrument(order.marketData.epic); model.Model = market; model.OrderSize = order.workingOrderData.orderSize; model.Direction = order.workingOrderData.direction; model.DealId = order.workingOrderData.dealId; model.CreationDate = order.workingOrderData.createdDate; model.GoodTillDate = order.workingOrderData.goodTillDate; model.OrderType = order.workingOrderData.orderType; model.StopDistance = order.workingOrderData.stopDistance; model.LimitDistance = order.workingOrderData.limitDistance; model.TimeInForce = order.workingOrderData.timeInForce; Orders.Add(model); } } } }
async Task ExecuteLoadOrdersCommand() { if (IsBusy) { return; } IsBusy = true; try { Orders.Clear(); var items = await OfflineSampleRepositoryContext.GetOrdersForUserIdAsync(User.Id); if (items != null) { foreach (var item in items) { Orders.Add(item); } } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async private void Search() { Orders.Clear(); // await MainDataSource.Instance.Context.Customers.LoadAsync(); // // foreach (var customer in MainDataSource.Instance.Context.Customers) // { // // } // var items = MainDataSource.Instance.Context.Customers.FirstOrDefault(x => x.OwnerAddress == SearchText || x.OwnerName == SearchText || x.OwnerPhone == SearchText); this.Customer = items; if (items != null) { var orders = MainDataSource.Instance.Context.Orders.Where(x => x.CustomerId == items.Id); foreach (var order in orders) { Orders.Add(order); } } }
public void Ask_Adds1Order_OnExistingLimit_With1Order() { // Arrange. var existingOrder = new Order { Shares = 100, Subscription = new Subscription { Owned = 100, UserId = _userId2 } }; var existingLimit = Limits.First(); existingLimit.AskHead = existingOrder; existingOrder.ParentLimit = existingLimit; Limits.Add(existingLimit); Orders.Add(existingOrder.Id, existingOrder); Subscriptions.Add(existingOrder.Subscription.UserId, existingOrder.Subscription); Subscriptions.Add(_userId1, new Subscription { Owned = 5, UserId = _userId1 }); // Act. Ask(_userId1, 1, 5); // Assert. var existingOrder2 = new Order { Shares = 100, Subscription = new Subscription { Owned = 100, UserId = _userId2 } }; var existingLimit2 = new Limit { Price = 1 * ScaleFactor }; existingOrder2.ParentLimit = existingLimit2; var order = new Order { Id = 1, Next = existingOrder2, Shares = 5, Subscription = new Subscription { Owned = 5, UserId = _userId1 } }; existingLimit2.AskHead = order; existingOrder2.Prev = order; order.ParentLimit = existingLimit2; Assert.AreEqual(1, Limits.Count); Assert.AreEqual(2, Orders.Count); Assert.AreEqual(2, Subscriptions.Count); CollectionAssert.AreEqual(new Limit[] { existingLimit2 }, Limits, _limitTestComparer); CollectionAssert.AreEqual(new Order[] { existingOrder2, order }, (ICollection)Orders.Values, _orderTestComparer); CollectionAssert.AreEqual(new Subscription[] { existingOrder2.Subscription, order.Subscription }, (ICollection)Subscriptions.Values, _subscriptionTestComparer); }
public enumStatus AddOrder(Order order) { string jsonDoc = order.ToString(); try { Orders.Add(order.Id, jsonDoc); if (!OrderTable.ContainsKey(order.UserID)) { List <Order> orders = new List <Order>(); OrderTable[order.UserID] = orders; } OrderTable[order.UserID].Add(order); return(enumStatus.OrderPlaced); } catch (Exception ex) { ServerLog.LogException(ex, string.Format("Add Order: {0}", order.ToString())); return(enumStatus.OrderPlaceError); } //lock (syncRoot) //{ //} }
public void addOrder(Order order) { Orders.Add(order); //callback order.driver = this; }
private void LoadOrders() { IQueryable <Order> orders = _db.Orders .Where(u => u.UserId == userId); if (!String.IsNullOrEmpty(OrdPrdSearchQuery)) { orders = orders.Where(op => op.OrderedProducts.Any(p => p.Product.Name.Contains(OrdPrdSearchQuery))); } var _orders = orders.OrderBy(o => o.Created) .Skip((ordPrdPage - 1) * productsAndOrdersPageSize) .Take(productsAndOrdersPageSize + 1).ToList(); if (_orders.Count == productsAndOrdersPageSize + 1) { isNextOrdPrdPageValid = true; _orders.RemoveAt(_orders.Count - 1); } else { isNextOrdPrdPageValid = false; } Orders.Clear(); foreach (Order o in _orders) { Orders.Add(o); } }
async Task ExecuteLoadOrdersCommand() { if (IsBusy) { return; } IsBusy = true; try { Orders.Clear(); var orders = await DataStore.GetOrdersAsync(true); foreach (var order in orders) { Orders.Add(order); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// Add an order to this position. /// </summary> /// <returns>The capital usage of this order</returns> public decimal AddOrder(Order order) { if (Instrument.ID != order.Instrument.ID) { throw new Exception("Incorrect instrument for position."); } if (Currency == null) { Currency = order.Currency; } Orders.Add(order); //Commissions HandleCommissions(order); //Profits if we're exiting CalculateProfits(order); CalculateDaysPnL(order); //Cost basis UpdateCostBasis(order); //Set the order's FIFO PnL SetFIFOPnL(order); decimal capitalUsage = CalculateCapitalUsage(order); Quantity += order.Quantity; return(capitalUsage); }
private OrderViewModel Add(Order ti) { var result = new OrderViewModel(ti, _cacheService, _applicationState); Orders.Add(result); return(result); }
private void SendOrder(Side side) { try { Trace.WriteLine(String.Format("Send New Order: Type={0} Side={1} Symbol=[{2}] Qty=[{3}] LimitPrice=[{4}] TIF={5}", this.OrderType.ToString(), side.ToString(), this.Symbol, this.OrderQtyString, this.LimitPriceString, this.TimeInForce.ToString())); Dictionary <int, string> customFieldsDict = new Dictionary <int, string>(); foreach (CustomFieldRecord cfr in this.CustomFields) { customFieldsDict[cfr.Tag] = cfr.Value; } int orderQty = int.Parse(this.OrderQtyString); decimal limitPrice = decimal.Parse(this.LimitPriceString); QuickFix.FIX42.NewOrderSingle nos = MessageCreator42.NewOrderSingle( customFieldsDict, this.OrderType, side, this.Symbol, orderQty, this.TimeInForce, limitPrice); OrderRecord r = new OrderRecord(nos); lock (_ordersLock) { Orders.Add(r); } _qfapp.Send(nos); } catch (Exception e) { Trace.WriteLine("Failed to send order\n" + e.ToString()); } }
internal void LoadMoreOrders() { for (int i = 0; i < GetOrderCount() / 2; i++) { Orders.Add(GenerateOrder(i)); } }
private OrderViewModel Add(Order ti) { var result = new OrderViewModel(ti); Orders.Add(result); return(result); }