public IResult Add(ProductOutput productOutput) { List <StockStore> products = _stockStoreDal.GetAll(p => p.Id == productOutput.ProductAcceptanceId); for (int i = 0; i < products.Count; i++) { if (products[i].Count < productOutput.Count) { return(new ErrorResult(Messages.CountError)); } else { StockStore product = new StockStore { Count = products[i].Count - productOutput.Count, Barcode = products[i].Barcode, Id = products[i].Id, UnitPrice = products[i].UnitPrice, DrawerId = products[i].DrawerId, ProductAcceptanceId = products[i].ProductAcceptanceId, ProductUnitId = products[i].ProductUnitId, ShelfId = products[i].ShelfId, StoreId = products[i].StoreId }; _stockStoreDal.Update(product); } } _productOutputDal.Add(productOutput); return(new SuccessResult(Messages.AddedProductOutput)); }
public IActionResult Delete(StockStore stockStore) { var result = _stockStoreService.Delete(stockStore); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IResult Add(StockStore stockStore) { var result = _stockStoreDal.GetAll(p => p.ProductAcceptanceId == stockStore.ProductAcceptanceId); if (result.Count != 0) { return(new ErrorResult(Messages.ProductAlreadyExist)); } _stockStoreDal.Add(stockStore); return(new SuccessResult(Messages.AddedStockStore)); }
public void SellAllStocks(Player[] players) { List <StockPurchaseRecord> purchaseRecords; foreach (Player player in players) { purchaseRecords = StockStore.GetPlayerPurchaseRecord(player.Name); foreach (StockPurchaseRecord purchaseRecord in purchaseRecords) { if (purchaseRecord.Quantity == 0) { continue; } player.AddCredit(purchaseRecord.Quantity * StockStore.GetPriceOfStock(purchaseRecord.StockName)); } } }
public List <PlayerStock> GetPlayerStocks(string playerName) { List <StockPurchaseRecord> purchaseRecords = StockStore.GetPlayerPurchaseRecord(playerName); List <PlayerStock> playerStocks = new List <PlayerStock>(purchaseRecords.Count); foreach (StockPurchaseRecord purchaseRecord in purchaseRecords) { if (purchaseRecord.Quantity == 0) { continue; } playerStocks.Add(new PlayerStock( purchaseRecord.StockName, purchaseRecord.Quantity, purchaseRecord.AverageStockPrice, StockStore.GetPriceOfStock(purchaseRecord.StockName))); } return(playerStocks); }
internal StockDetailsManager() { // Cannot be initialized in field because Player & Stock attributes are not initialized yet PurchaseRecord = StockStore.GetPurchaseRecord(Player.Name, Stock.Name); QuantityChange = PurchaseRecord.Quantity; }
internal void InitializeGame(string[] names) { GameStore.InitPlayers(names); NewsStore.ResetNews(); StockStore.LoadPurchaseRecords(); }
public IResult Update(StockStore stockStore) { _stockStoreDal.Update(stockStore); return(new SuccessResult(Messages.UpdatedStockStore)); }
public IResult Delete(StockStore stockStore) { _stockStoreDal.Delete(stockStore); return(new SuccessResult(Messages.DeletedStockStore)); }