api updates

This commit is contained in:
Isaac Levin 2019-05-31 09:56:11 -04:00
parent d6a31a5f67
commit 6743364423
2 changed files with 3 additions and 29 deletions

View File

@ -17,18 +17,6 @@ namespace Company.WebApplication1.Controllers
[ApiController] [ApiController]
public class WeatherController : ControllerBase public class WeatherController : ControllerBase
{ {
[HttpGet]
public ActionResult<WeatherResult> GetWeatherResult(string location)
{
var rng = new Random();
return new WeatherResult
{
Location = location,
Temperature = rng.Next(-20, 55),
TemperatureUnit = TemperatureUnit.Celsius
};
}
[HttpGet] [HttpGet]
public ActionResult<WeatherResult> GetWeatherForecasts(string location, TemperatureUnit unit) public ActionResult<WeatherResult> GetWeatherForecasts(string location, TemperatureUnit unit)
{ {

View File

@ -1,4 +1,4 @@
namespace WebApplication1.Controllers namespace WebApplication1.Controllers
open System open System
open System.Collections.Generic open System.Collections.Generic
@ -22,25 +22,11 @@ type WeatherController () =
inherit ControllerBase() inherit ControllerBase()
[<HttpGet>] [<HttpGet>]
[<Route("GetWeatherByLocationWithUnit")>]
member this.Get(location:string, unit: string) = member this.Get(location:string, unit: string) =
let rnd = System.Random() let rnd = System.Random()
let result:WeatherResult = { let result:WeatherResult = {
Location = location; Location = location;
Temperature = rnd.Next(-20,55); Temperature = rnd.Next(-20,55);
TemperatureUnit = System.Enum.Parse(typeof<TemperatureUnit>,unit) TemperatureUnit = unit
:?> TemperatureUnit
}
ActionResult<WeatherResult>(result)
[<HttpGet>]
[<Route("GetWeatherByLocation")>]
member this.Get(location:string) =
let rnd = System.Random()
let result:WeatherResult = {
Location = location;
Temperature = rnd.Next(-20,55);
TemperatureUnit = TemperatureUnit.Celsius
} }
ActionResult<WeatherResult>(result) ActionResult<WeatherResult>(result)