예제 #1
0
 public Stock CreateStock(Stock stock)
 {
     if (stock.StockId == 0)
     {
         return(stockRepository.Create(stock));;
     }
     return(stock); //exception!!!
 }
        private void InsertStock(Company createdCompany, string stockCode, int bussinessCategoryId)
        {
            if (!string.IsNullOrEmpty(stockCode))
            {
                var bussinessCategory = _bussinessCategoryRepository.Read(bussinessCategoryId);
                var stock             = _stockRepository.Create(createdCompany, bussinessCategory, stockCode);

                _aggregateHistoryRepository.Create(stock, DateTime.Now, DateTime.Now);
            }
        }
예제 #3
0
        public async Task <ActionResult <Stock> > PostStock(Stock stock)
        {
            var result = await _stockRepository.Create(stock);

            if (result == null)
            {
                return(BadRequest());
            }

            return(CreatedAtAction("GetStock", new { id = stock.Id }, stock));
        }
        public void AddingStockToStockRepository()
        {
            _stockRepository.Create(new Domain.Stock
            {
                Id     = 99,
                Symbol = "TEST",
                Trades = new List <Trade>()
            });

            Assert.IsTrue(_stockRepository.GetBySymbol("TEST") != null);
        }
예제 #5
0
        public async Task <IActionResult> CreateStock(StockCreationDto dto)
        {
            var newStock = new StockCreationDto
            {
                Quantity = dto.Quantity
            };

            await _stockRepository.Create(newStock);

            return(Ok(dto));
        }
예제 #6
0
        private Branch CreateBranch(Branch branch)
        {
            branch = branchRepository.Create(branch);

            var stock = new Stock {
                BranchId = branch.BranchId, StockId = 0
            };

            stockRepository.Create(stock);

            return(branch);
        }
예제 #7
0
 public IHttpActionResult Save(Stock product)
 {
     _stockRepository.Create(product);
     return(Ok());
 }
예제 #8
0
        public string Get(string setting)
        {
            if (setting == "init")
            {
                _productRepository.Remove();
                _stockRepository.Remove();
                var title = _productRepository.CreateIndex();

                Product product = new Product();

                product = _productRepository.Create(new Product()
                {
                    Title      = "Toshiba L312",
                    Price      = 3800,
                    CategoryId = "5dcb0919d1e4079b69a897d0"
                });

                int quantity = 0;
                if (_stockRepository.Get(product.Id).Result != null)
                {
                    quantity = _stockRepository.Get(product.Id).Result.Quantity;
                }

                _stockRepository.Create(new Stock()
                {
                    ProductId = product.Id,
                    Quantity  = quantity + 1
                });

                product = _productRepository.Create(new Product()
                {
                    Title      = "Nike Air",
                    Price      = 650,
                    CategoryId = "5dcb09abd1e4079b69a897d2"
                });

                quantity = 0;
                if (_stockRepository.Get(product.Id).Result != null)
                {
                    quantity = _stockRepository.Get(product.Id).Result.Quantity;
                }

                _stockRepository.Create(new Stock()
                {
                    ProductId = product.Id,
                    Quantity  = quantity + 1
                });

                product = _productRepository.Create(new Product()
                {
                    Title      = "Kulaklik",
                    Price      = 150,
                    CategoryId = "5dcb08e2d1e4079b69a897cf"
                });

                quantity = 0;
                if (_stockRepository.Get(product.Id).Result != null)
                {
                    quantity = _stockRepository.Get(product.Id).Result.Quantity;
                }

                _stockRepository.Create(new Stock()
                {
                    ProductId = product.Id,
                    Quantity  = quantity + 1
                });

                product = _productRepository.Create(new Product()
                {
                    Title      = "Macbook Pro",
                    Price      = 17000,
                    CategoryId = "5dcb0919d1e4079b69a897d0"
                });

                quantity = 0;
                if (_stockRepository.Get(product.Id).Result != null)
                {
                    quantity = _stockRepository.Get(product.Id).Result.Quantity;
                }

                _stockRepository.Create(new Stock()
                {
                    ProductId = product.Id,
                    Quantity  = quantity + 1
                });

                return("Database ProductsDb was created, and collection 'Product' was filled with 4 sample items");
            }

            return("Unknown");
        }
예제 #9
0
 public void Post([FromBody] Stock stock)
 {
     _stockRepository.Create(stock);
 }
 public void CreateStock(StockManagementModel stock)
 {
     _stockRepository.Create(stock);
 }