예제 #1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
                return;

            IsBusy = true;

            try
            {
                Stocks.Clear();
                var stocks = await StockDataStore.GetStocksAsync();
                foreach (var stock in stocks)
                {
                    Stocks.Add(stock);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #2
0
        public void notify(StartWatchingSymbol message)
        {
            var presenter = new StockViewModel(symbol: message.Symbol, builder: builder);

            presenter.present();
            Stocks.Add(presenter);
        }
예제 #3
0
 public void AddStock(Stock stock)
 {
     if (!(Stocks.Exists(s => s.Symbol == stock.Symbol)))            //If doesn't exist, add stock to list.
     {
         Stocks.Add(stock);
     }
 }
예제 #4
0
        public void Build(Resource resource, IEnumerable cells)
        {
            foreach (var c in cells)
            {
                Cell  cell  = (Cell)c;
                float stock = cell.GetStock(resource.Id);
                if (stock > 0.0f)
                {
                    StockCells.Add(cell);
                    Stocks.Add(cell.Stocks);
                    TotalStock += stock;
                }

                float demand = cell.GetDemandFor(resource.Id);
                if (demand > 0.0f)
                {
                    DemandCells.Add(cell);
                    TotalDemand += demand;
                }
            }

            StockValues = new float[StockCells.Count];
            for (int j = 0; j < StockCells.Count; j++)
            {
                StockValues[j] = StockCells[j].GetStock(resource.Id);
            }

            DemandValues = new float[DemandCells.Count];
            for (int i = 0; i < DemandCells.Count; i++)
            {
                DemandValues[i] = DemandCells[i].GetDemandFor(resource.Id);
            }
        }
        async Task ExecuteLoadStocksCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Stocks.Clear();
                var stocks = await StoreDataStore.GetStoreStocksAsync(App.currentStore.StoreId, true);

                foreach (var stock in stocks)
                {
                    Stocks.Add(stock);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #6
0
        public void AddStock(Stock stock, string Typeprod)
        {
            ShopsStocks Stock = new ShopsStocks();

            Stock.stock         = stock;
            Stock.Typeofproduct = Typeprod;
            Stocks.Add(Stock);
        }
예제 #7
0
 public void EndInit()
 {
     foreach (var catalog in ReferencedCatalogs)
     {
         foreach (var stock in catalog.Stocks)
         {
             Stocks.Add(stock);
         }
     }
 }
예제 #8
0
        public void AddStock(string symbol)
        {
            Stock newStock = new Stock()
            {
                Name = symbol
            };

            if (!Stocks.Contains(newStock))
            {
                Stocks.Add(newStock);
            }
            SelectedStock = Stocks.First(Stock => Stock.Name == newStock.Name);
        }
예제 #9
0
 private void CreateStocks()
 {
     foreach (var partId in PartIds)
     {
         Stocks.Add(new StockTaking()
         {
             PartId    = partId,
             CreatedOn = DateTime.Now,
             CreatedBy = RuntimeSettings.CurrentUser.UserId,
             TenantId  = RuntimeSettings.TenantId
         });
     }
 }
예제 #10
0
        public Stock PostStock(Stock stock)
        {
            var item = Stocks.FirstOrDefault(c => c.StockCode == stock.StockCode);

            if (item != null)
            {
                item = stock;
                return(item);
            }
            else
            {
                Stocks.Add(stock);
                return(stock);
            }
        }
예제 #11
0
        public void Update()
        {
            Stocks.Clear();

            using (IStockController controller = factory.CreateStockController())
            {
                DataControllerMessage <IEnumerable <StockDisplayDTO> > message = controller.GetAll();
                if (message.IsSuccess)
                {
                    foreach (StockDisplayDTO stock in message.Data)
                    {
                        Stocks.Add(stock);
                    }
                }
            }
        }
예제 #12
0
 private void Initialize()
 {
     if (!Stocks.Any())
     {
         Stocks.Add(new Stock {
             FreePlace = 500000, Name = "Stock 1"
         });
         Stocks.Add(new Stock {
             FreePlace = 700000, Name = "Stock 2"
         });
         Stocks.Add(new Stock {
             FreePlace = 900000, Name = "Stock 3"
         });
         SaveChanges();
     }
 }
예제 #13
0
 private void AddNewStock()
 {
     Stocks.Add(NewStock);
     NewStock.ValidateAll();
     BondQuantity           = Stocks.Count(p => p.StockType == StockType.BondTypeName);
     EquityQuantity         = Stocks.Count(p => p.StockType == StockType.EquityTypeName);
     TotalBondMarketValue   = Stocks.Where(p => p.StockType == StockType.BondTypeName).Sum(s => s.MarketValue ?? 0);
     TotalEquityMarketValue = Stocks.Where(p => p.StockType == StockType.EquityTypeName).Sum(s => s.MarketValue ?? 0);
     TotalBondWeight        = Stocks.Where(p => p.StockType == StockType.BondTypeName).Sum(s => s.StockWeight ?? 0);
     TotalEquityWeight      = Stocks.Where(p => p.StockType == StockType.EquityTypeName).Sum(s => s.StockWeight ?? 0);
     TotalQuantity          = Stocks.Count;
     TotalMarketValue       = Stocks.Sum(s => s.MarketValue ?? 0);
     TotalWeight            = Stocks.Sum(s => s.StockWeight ?? 0);
     NewStock.Model.Notify("StockTypeQuantity", NewStock.Model.StockType == StockType.BondTypeName ? BondQuantity : EquityQuantity);
     ClearStockData();
 }
예제 #14
0
 public int UpdateReferenceByMarket(List <string> lst, Dictionary <string, Warrant> warrants)
 {
     Console.WriteLine("All TSC/OTC Size: " + lst.Count);
     for (int i = 0; i < lst.Count; ++i)
     {
         string[] substring = lst[i].Split('|');
         Warrant  targetWarrant;
         if (!warrants.TryGetValue(substring[0], out targetWarrant))
         {
             PI30001 stock = quoteCom.GetProductSTOCK(substring[0]);
             Stock   st    = new Stock(stock.StockNo, stock.StockName, Convert.ToUInt32(stock.Ref_Price));
             Stocks.Add(stock.StockNo, st);
         }
     }
     Console.WriteLine("Stock Size: " + Stocks.Count);
     return(0);
 }
예제 #15
0
        /// <summary>
        /// Initializes the stocks.
        /// </summary>
        private void InitializeStocks()
        {
            var msft = new Stock("Microsoft", "MSFT");
            var appl = new Stock("Apple", "AAPL");
            var tsla = new Stock("Tesla", "TSLA");
            var goog = new Stock("Google", "GOOG");

            Stocks.Add(msft);
            Stocks.Add(appl);
            Stocks.Add(tsla);
            Stocks.Add(goog);
            SelectedStock = Stocks[0];

            foreach (var stock in Stocks)
            {
                stock.StartUpdatingPriceData();
            }
        }
        public void IncreaseStock(int productId, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException($"Cannot increase {count} product to stock.");
            }
            FileStream locker = _FileLocker.LockObj(_productAndStockLockerFile);

            var product = FindProductInner(productId);

            try
            {
                if (product != null)
                {
                    GetStocks();

                    var stock = Stocks.FirstOrDefault(s => s.ProductId == productId);

                    if (stock != null)
                    {
                        stock.Count += count;
                    }
                    else
                    {
                        Stocks.Add(new ProductItem()
                        {
                            ProductId = productId, Count = count
                        });
                    }

                    _jsonHandler.SaveRecords(_stockFile, Stocks);
                }
                else
                {
                    throw new IndexOutOfRangeException($"Product {productId} does not exist.");
                }
            }
            finally
            {
                _FileLocker.UnlockObj(locker);
            }
        }
예제 #17
0
        private StockMarket([NotNull] XDocument document) : this()
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            try
            {
                foreach (XElement stock in document.Root.Elements( ))
                {
                    Stocks.Add(new Stock(stock));
                }
            }
            catch (NullReferenceException e)
            {
                throw new ArgumentException($"{nameof(document)} has wrong data or lack of data", e);
            }

            //ToDo LoadStocks
        }
예제 #18
0
        /// <summary>
        /// Method to add stocks to the collection
        /// </summary>
        /// <param name="obj"></param>
        private void AddStock(object obj)
        {
            if (Price == null)
            {
                return;
            }
            if (Price == null)
            {
                return;
            }
            if (Stocks == null)
            {
                Stocks = new ObservableCollection <Stock>();
            }
            try
            {
                string name = $"{StockType.ToString()}{Stocks.Where(x => x.StockType == stockType).Count() + 1}";
                Stocks.Add(new Stock()
                {
                    StockType = this.StockType,
                    Name      = name,
                    Price     = (float)this.Price,
                    Quantity  = (float)this.Quantity
                });

                UpdateEquitySummary();
                UpdateBondSummary();
                TotalMarketValue    = Stocks.Select(x => x.MarketValue).Sum();
                TotalNumberOfStocks = Stocks.Count();
                TotalStockWeight    = Stocks.Select(x => x.StockWeight).Sum();
                UpdateStockWeight();
                OnPropertyChanged("Stocks");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Exception - AddStock, Details : {ex.Message}");
            }
        }
예제 #19
0
        public StocksViewModel(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher, ICorrectionsCreator correctionsCreator)
        {
            _queryDispatcher    = queryDispatcher;
            _commandDispatcher  = commandDispatcher;
            _correctionsCreator = correctionsCreator;

            AddStockCommand = new RelayCommand(() =>
            {
                var stock = new Stock();
                stock.Balance.PropertyChanged += BalanceOnPropertyChanged;
                Stocks.Add(stock);
                stock.IsPropertyChangedEnabled         = true;
                stock.Balance.IsPropertyChangedEnabled = true;
            });
            RemoveCommand = new RelayCommand <Stock>(x =>
            {
                MessengerInstance.Send(new DeleteStockMessage(x));
                Stocks.Remove(x);

                _commandDispatcher.Execute(new DeleteStockCommand(Mapper.Map <DtoStock>(x)));
            });
            //todo: think what should happen on stock delete...
        }
예제 #20
0
 private void OnSaveStockCompleted(Stock stock)
 {
     if (_isUpdated)
     {
         SelectedStock.Date       = stock.Date;
         SelectedStock.Quantity   = stock.Quantity;
         SelectedStock.TotalPrice = stock.TotalPrice;
         foreach (var stockDetail in SelectedStock.Details)
         {
             var d = stock.Details.FirstOrDefault(x => x.ProductId == stockDetail.ProductId);
             if (d == null)
             {
                 continue;
             }
             stockDetail.Quantity = d.Quantity;
             stockDetail.Price    = d.Price;
         }
     }
     else
     {
         Stocks.Add(stock);
     }
 }
 int ICollectionModifier <Stock> .Add(Stock entity) => Stocks.Add(entity).Id;
예제 #22
0
 internal void AddStock(string symbol, string company, int min, int max, double spread, double volatility, double shift = 0, long increment = 0)
 {
     Stocks.Add(new RonStock(symbol, company, min, max, spread, volatility, shift, increment));
 }
예제 #23
0
 public void AddStock(Stock stock)
 {
     Stocks.Add(stock);
     stock.Owner = this;
 }
예제 #24
0
 public int Add(Stock entity) => Stocks.Add(entity).Id;
예제 #25
0
 public void Add(Stock entity) => Stocks.Add(entity);
예제 #26
0
 private void SaveAsset(Stock asset)
 {
     Stocks.Add(asset);
     SaveChanges();
 }