diff --git a/.vscode/launch.json b/.vscode/launch.json index 20569db..5d77af8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -24,7 +24,8 @@ }, "sourceFileMap": { "/Views": "${workspaceFolder}/Views" - } + }, + "enableStepFiltering": false }, { "name": ".NET Core Attach", diff --git a/OSI-API.Business/OSI-API.Business.csproj b/OSI-API.Business/OSI-API.Business.csproj new file mode 100644 index 0000000..0943e83 --- /dev/null +++ b/OSI-API.Business/OSI-API.Business.csproj @@ -0,0 +1,13 @@ + + + + net5.0 + OSI_API.Business + + + + + + + + diff --git a/OSI-API.Business/Objects/InvoiceRequestResponse.cs b/OSI-API.Business/Objects/InvoiceRequestResponse.cs new file mode 100644 index 0000000..3c96618 --- /dev/null +++ b/OSI-API.Business/Objects/InvoiceRequestResponse.cs @@ -0,0 +1,9 @@ +namespace OSI.API.Business.Objects +{ + public class InvoiceObject + { + public int InvoiceNumber { get; set; } + public float InvoiceAmount { get; set; } + public float Discount { get; set; } + } +} \ No newline at end of file diff --git a/OSI-API/Controllers/InvoicesController.cs b/OSI-API/Controllers/InvoicesController.cs index 4d4e46e..f6b8239 100644 --- a/OSI-API/Controllers/InvoicesController.cs +++ b/OSI-API/Controllers/InvoicesController.cs @@ -4,43 +4,41 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using OSI.API.Business.Objects; namespace OSI.API.Controllers { [Route("api/v{version:apiVersion}/[controller]")] [ApiController] - public class InvoicesController : ControllerBase + public class InvoicesController : EndpointBase { - // GET: api/Invoices - [HttpGet] - public IEnumerable Get() + public override IActionResult Delete(int id) { - return new string[] { "value1", "value2" }; + return NotFound(); } - // GET: api/Invoices/5 - [HttpGet("{id}")] - public string Get(int id) + public override IActionResult Get() { - return "value"; + throw new NotImplementedException(); } - // POST: api/Invoices - [HttpPost] - public void Post([FromBody] string value) + public override IActionResult Get(int id) { + return new JsonResult(id); } - // PUT: api/Invoices/5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) + public override IActionResult Post([FromBody] InvoiceObject input) { + throw new NotImplementedException(); } - // DELETE: api/Invoices/5 - [HttpDelete("{id}")] - public void Delete(int id) + public override IActionResult Put(int id, [FromBody] InvoiceObject input) { + return CreatedAtAction( + "Get", + routeValues: new { id = input.InvoiceAmount }, + value: Get(id) + ); } } } diff --git a/OSI-API/Controllers/_EndpointBase.cs b/OSI-API/Controllers/_EndpointBase.cs new file mode 100644 index 0000000..64d8270 --- /dev/null +++ b/OSI-API/Controllers/_EndpointBase.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; + +namespace OSI.API.Controllers +{ + public abstract class EndpointBase : ControllerBase + { + [HttpGet] + public abstract IActionResult Get(); + + // GET: api/Clients/5 + [HttpGet("{id}")] + public abstract IActionResult Get(int id); + + // POST: api/Clients + [HttpPost] + public abstract IActionResult Post([FromBody] A input); + + // PUT: api/Clients/5 + [HttpPut("{id}")] + public abstract IActionResult Put(int id, [FromBody] A input); + + // DELETE: api/Clients/5 + [HttpDelete("{id}")] + public abstract IActionResult Delete(int id); + } +} \ No newline at end of file diff --git a/OSI-API/OSI-API.csproj b/OSI-API/OSI-API.csproj index 3d0c0e1..601b417 100644 --- a/OSI-API/OSI-API.csproj +++ b/OSI-API/OSI-API.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/OSI-API/Program.cs b/OSI-API/Program.cs index 83c815c..a601377 100644 --- a/OSI-API/Program.cs +++ b/OSI-API/Program.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace OSI_API +namespace OSI.API { public class Program { diff --git a/OSI-API/Startup.cs b/OSI-API/Startup.cs index e898e20..d122abf 100644 --- a/OSI-API/Startup.cs +++ b/OSI-API/Startup.cs @@ -12,7 +12,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; -namespace OSI_API +namespace OSI.API { public class Startup { @@ -56,7 +56,7 @@ namespace OSI_API }); } - app.UseHttpsRedirection(); + // app.UseHttpsRedirection(); app.UseRouting();