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); } }
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); }
public async Task <IActionResult> CreateStock(StockCreationDto dto) { var newStock = new StockCreationDto { Quantity = dto.Quantity }; await _stockRepository.Create(newStock); return(Ok(dto)); }
private Branch CreateBranch(Branch branch) { branch = branchRepository.Create(branch); var stock = new Stock { BranchId = branch.BranchId, StockId = 0 }; stockRepository.Create(stock); return(branch); }
public IHttpActionResult Save(Stock product) { _stockRepository.Create(product); return(Ok()); }
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"); }
public void Post([FromBody] Stock stock) { _stockRepository.Create(stock); }
public void CreateStock(StockManagementModel stock) { _stockRepository.Create(stock); }