diff --git a/OSI-API/Controllers/ClientsController.cs b/OSI-API/Controllers/ClientsController.cs new file mode 100644 index 0000000..e2a30f1 --- /dev/null +++ b/OSI-API/Controllers/ClientsController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ClientsController : ControllerBase + { + // GET: api/Clients + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Clients/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Clients + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Clients/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Clients/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/ExpensesController.cs b/OSI-API/Controllers/ExpensesController.cs new file mode 100644 index 0000000..82e6819 --- /dev/null +++ b/OSI-API/Controllers/ExpensesController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ExpensesController : ControllerBase + { + // GET: api/Expenses + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Expenses/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Expenses + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Expenses/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Expenses/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/InvoicesController.cs b/OSI-API/Controllers/InvoicesController.cs new file mode 100644 index 0000000..6aa8174 --- /dev/null +++ b/OSI-API/Controllers/InvoicesController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class InvoicesController : ControllerBase + { + // GET: api/Invoices + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Invoices/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Invoices + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Invoices/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Invoices/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/POsController.cs b/OSI-API/Controllers/POsController.cs new file mode 100644 index 0000000..516e10c --- /dev/null +++ b/OSI-API/Controllers/POsController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class POsController : ControllerBase + { + // GET: api/POs + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/POs/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/POs + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/POs/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/POs/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/PaymentsController.cs b/OSI-API/Controllers/PaymentsController.cs new file mode 100644 index 0000000..f3cdae5 --- /dev/null +++ b/OSI-API/Controllers/PaymentsController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class PaymentsController : ControllerBase + { + // GET: api/Payments + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Payments/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Payments + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Payments/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Payments/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/ReportsController.cs b/OSI-API/Controllers/ReportsController.cs new file mode 100644 index 0000000..02c2c62 --- /dev/null +++ b/OSI-API/Controllers/ReportsController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ReportsController : ControllerBase + { + // GET: api/Reports + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Reports/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Reports + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Reports/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Reports/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/UsersController.cs b/OSI-API/Controllers/UsersController.cs new file mode 100644 index 0000000..51fb69b --- /dev/null +++ b/OSI-API/Controllers/UsersController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OSI.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class UsersController : ControllerBase + { + // GET: api/Users + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/Users/5 + [HttpGet("{id}", Name = "Get")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Users + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Users/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/Users/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OSI-API/Controllers/WeatherForecastController.cs b/OSI-API/Controllers/WeatherForecastController.cs deleted file mode 100644 index a1b1550..0000000 --- a/OSI-API/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; - -namespace OSI_API.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet] - public IEnumerable Get() - { - var rng = new Random(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateTime.Now.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/OSI-API/OSI-API.csproj b/OSI-API/OSI-API.csproj index 526e3d1..3d0c0e1 100644 --- a/OSI-API/OSI-API.csproj +++ b/OSI-API/OSI-API.csproj @@ -6,6 +6,8 @@ + + diff --git a/OSI-API/Startup.cs b/OSI-API/Startup.cs index d5f3e7a..e898e20 100644 --- a/OSI-API/Startup.cs +++ b/OSI-API/Startup.cs @@ -32,6 +32,13 @@ namespace OSI_API { c.SwaggerDoc("v1", new OpenApiInfo { Title = "OSI_API", Version = "v1" }); }); + + services.AddApiVersioning(options => + { + options.ReportApiVersions = true; + options.AssumeDefaultVersionWhenUnspecified = true; + options.DefaultApiVersion = new ApiVersion(1, 0); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -41,7 +48,12 @@ namespace OSI_API { app.UseDeveloperExceptionPage(); app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "OSI_API v1")); + // app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "OSI_API v1")); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Delta.Net.Core.API v1"); + c.RoutePrefix = "api"; + }); } app.UseHttpsRedirection(); @@ -52,8 +64,10 @@ namespace OSI_API app.UseEndpoints(endpoints => { + endpoints.MapControllerRoute(name: "default", pattern: "api/v{version:apiVersion}/{controller}/{action}/{id?}", null); endpoints.MapControllers(); }); + } } } diff --git a/OSI-API/WeatherForecast.cs b/OSI-API/WeatherForecast.cs deleted file mode 100644 index fe7a93d..0000000 --- a/OSI-API/WeatherForecast.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace OSI_API -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } - } -}