public async Task <IActionResult> Get(string id) { StockVM stock = await _stockService.GetStockAsync(id); if (stock == null) { return(NotFound()); } return(Ok(stock)); }
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); }
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); }
public async Task <IActionResult> Post(StockVM stock) { var result = await _stockService.AddStockAsync(stock); return(Ok(result)); }
public async Task <StockVM> AddStockAsync(StockVM stockVM) { var stock = await _mediator.Send(new CreateRequest <StockVM>(stockVM)); return(stock); }