public async Task <GetItemsPricesModel> GetItemsPrices(GetItemsPricesInputModel model) { var result = await this.httpClient.PostAsJsonAsync("api/items/prices", model); if (!result.IsSuccessStatusCode) { return(null); } return(await result.Content.ReadFromJsonAsync <GetItemsPricesModel>()); }
public async Task <IActionResult> GetItemsPrices([FromBody] GetItemsPricesInputModel inputModel) { var success = Enum.TryParse <PriceSelector>(inputModel.PriceSelector, out var priceSelector); if (!success) { return(this.BadRequest()); } var items = await this.itemsService.GetLatestItemsPricesAsync(inputModel.ItemIds); var model = new GetItemsPricesModel() { Prices = items.Select(i => new GetItemsPricesPriceModel() { Id = i.Key, Time = i.Value.Time, Price = GetPrice(i.Value, priceSelector), }), }; return(this.Ok(model)); }