public IBuilder GetBuilder(IStockDTO stock)
        {
            if (stock == null)
            {
                throw new ArgumentNullException(nameof(stock));
            }

            return(strategy[stock.GetType()]());
        }
        public virtual IStock Create(IStockDTO stockDto, decimal totalMarketValue)
        {
            if (stockDto == null)
            {
                throw new ArgumentNullException(nameof(stockDto));
            }

            var stock = GetInstance();

            PropertyMapper.Map(source: stockDto, dectination: stock);

            stock.MarketValue     = Math.Round(CalculateMarketValue(stock.Price, stock.Quantity), 2);
            stock.TransactionCost = Math.Round(CalculateTransactionCost(stock.MarketValue), 2);
            stock.StockWeight     = Math.Round(CalculateStockWeight(totalMarketValue: totalMarketValue,
                                                                    marketValue: stock.MarketValue), 2);

            return(stock);
        }
예제 #3
0
        protected Task <DynamicParameters> SetParameterAsync(String command, IStockDTO stockDTO)
        {
            try
            {
                return(Task.Run(() =>
                {
                    var dynamicParameter = new DynamicParameters();

                    dynamicParameter.Add("@Command", command, DbType.String, ParameterDirection.Input);
                    dynamicParameter.Add("@StockIdentity", stockDTO.StockIdentity, DbType.Guid, ParameterDirection.Input);
                    dynamicParameter.Add("@ProductName", stockDTO.ProductName, DbType.String, ParameterDirection.Input);
                    dynamicParameter.Add("@Quantity", stockDTO.Quantity, DbType.String, ParameterDirection.Input);

                    return dynamicParameter;
                }));
            }
            catch
            {
                throw;
            }
        }
 public void AddStock(IStockDTO stock)
 {
     stocks.Add(stock);
 }