Пример #1
0
        public async Task <IActionResult> Get(string id)
        {
            StockVM stock = await _stockService.GetStockAsync(id);

            if (stock == null)
            {
                return(NotFound());
            }

            return(Ok(stock));
        }
Пример #2
0
        public static Stock ToEntity(this StockVM stockVM)
        {
            var stock = new Stock()
            {
                Id          = stockVM.Id,
                Name        = stockVM.Name,
                Symbol      = stockVM.Symbol,
                Type        = stockVM.Type,
                Region      = stockVM.Region,
                MarketOpen  = stockVM.MarketOpen,
                MarketClose = stockVM.MarketClose,
                TimeZone    = stockVM.TimeZone,
                Currency    = stockVM.Currency,
                Quote       = stockVM.Quote?.ToEntity()
            };

            return(stock);
        }
Пример #3
0
        public static StockVM ToVM(this Stock stock)
        {
            var stockVM = new StockVM()
            {
                Id          = stock.Id,
                Name        = stock.Name,
                Symbol      = stock.Symbol,
                Type        = stock.Type,
                Region      = stock.Region,
                MarketOpen  = stock.MarketOpen,
                MarketClose = stock.MarketClose,
                TimeZone    = stock.TimeZone,
                Currency    = stock.Currency,
                Quote       = stock.Quote?.ToVM()
            };

            return(stockVM);
        }
Пример #4
0
        public async Task <IActionResult> Post(StockVM stock)
        {
            var result = await _stockService.AddStockAsync(stock);

            return(Ok(result));
        }
Пример #5
0
        public async Task <StockVM> AddStockAsync(StockVM stockVM)
        {
            var stock = await _mediator.Send(new CreateRequest <StockVM>(stockVM));

            return(stock);
        }