public async Task <IActionResult> GetCosts([FromRoute] string period, [FromQuery] long vehicleId) { StatsPeriod periodValue; if (!Enum.TryParse(period, true, out periodValue)) { return(NotFound()); } var stats = new StatsResponse() { FuelCost = await _statsService.GetCost(periodValue, vehicleId, ExpenseType.Fuel), FuelUsage = await _statsService.GetFuelUsage(periodValue, vehicleId), InsuranceCost = await _statsService.GetCost(periodValue, vehicleId, ExpenseType.Insurance), OtherCost = await _statsService.GetCost(periodValue, vehicleId, ExpenseType.Other), ServiceCost = await _statsService.GetCost(periodValue, vehicleId, ExpenseType.Service), SparePartCost = await _statsService.GetCost(periodValue, vehicleId, ExpenseType.SparePart), Total = await _statsService.GetCost(periodValue, vehicleId) }; return(Ok(stats)); }