-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate RandomValueController when random value option is set
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/RandomValueController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Company.WebApplication.CS.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class RandomValueController : ControllerBase | ||
{ | ||
private IConfiguration _config; | ||
|
||
public RandomValueController(IConfiguration config) | ||
{ | ||
_config = config; | ||
} | ||
|
||
[HttpGet] | ||
public dynamic Index() | ||
{ | ||
return new | ||
{ | ||
intVal = _config["random:int"], | ||
longVal = _config["random:long"], | ||
int10 = _config["random:int(10)"], | ||
long10 = _config["random:long(100)"], | ||
int10_20 = _config["random:int(10,20)"], | ||
long100_200 = _config["random:long(100,200)"], | ||
uuid = _config["random:uuid"], | ||
stringVal = _config["random:string"] | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/RandomValueController.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Company.WebApplication.FS.Controllers | ||
|
||
open Microsoft.AspNetCore.Mvc | ||
open Microsoft.Extensions.Configuration | ||
open Microsoft.Extensions.Logging | ||
|
||
type RandomValue = {intVal : int; longVal: int64; int10: int; long10: int64; int10_20: int; long100_200: int64; uuid: string; stringVal: string} | ||
|
||
[<ApiController>] | ||
[<Route("[controller]")>] | ||
type RandomValueController (logger : ILogger<RandomValueController>, _config: IConfiguration) = | ||
inherit ControllerBase() | ||
|
||
[<HttpGet>] | ||
member _.Get() = | ||
{ intVal = int _config.["random:int"] | ||
longVal = int64 _config.["random:long"] | ||
int10 = int _config.["random:int(10)"] | ||
long10 = int64 _config.["random:long(100)"] | ||
int10_20 = int _config.["random:int(10,20)"] | ||
long100_200 = int64 _config.["random:long(100,200)"] | ||
uuid = _config.["random:uuid"] | ||
stringVal = _config.["random:string"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters