public async Task <IActionResult> Test([FromBody] TestReq input) { switch (input.Id) { case 1: var resp = new TestResp { Id = 1, Info = $"The Msg from request is: {input.Msg.ToUpper()}" }; return(Ok(resp)); case 2: return(BadRequest(new Error { ErrorCode = 400, ErrorMsg = "Error...." })); case 3: return(Unauthorized()); case 4: return(NotFound(new string[] { "404", "Not", "Found" })); case 5: return(StatusCode((int)HttpStatusCode.InternalServerError)); default: return(StatusCode((int)HttpStatusCode.NotImplemented)); } }
public async Task <IActionResult> Test([FromRoute] int input) { switch (input) { case 1: var resp = new TestResp { Id = 1, Info = "Ok from controller version 1.X" }; return(Ok(resp)); case 2: return(BadRequest(new Error { ErrorCode = 400, ErrorMsg = "Error...." })); case 3: return(Unauthorized()); case 4: return(NotFound(new string[] { "404", "Not", "Found" })); case 5: return(StatusCode((int)HttpStatusCode.InternalServerError)); default: return(StatusCode((int)HttpStatusCode.NotImplemented)); } }