diff --git a/Program.cs b/Program.cs index 39428cd..0cf43b7 100644 --- a/Program.cs +++ b/Program.cs @@ -13,6 +13,7 @@ builder.Services.Configure(o => { o.ViewLocationFormats.Add("/WebInterface/Views/{1}/{0}" + RazorViewEngine.ViewExtension); o.ViewLocationFormats.Add("/WebInterface/Views/Shared/{0}" + RazorViewEngine.ViewExtension); }); +builder.Services.AddSwaggerGen(); var app = builder.Build(); @@ -29,5 +30,11 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); +app.UseSwagger(); + +app.UseSwaggerUI(c => +{ + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample API"); +}); app.Run(); diff --git a/WebInterface/Controllers/EmployeeControler.cs b/WebInterface/Controllers/EmployeeControler.cs new file mode 100644 index 0000000..0d28c4c --- /dev/null +++ b/WebInterface/Controllers/EmployeeControler.cs @@ -0,0 +1,41 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using vassago.Models; + +namespace vassago.Controllers; + +[Route("[controller]")] +[ApiController] +public class EmployeeController : ControllerBase +{ + [HttpGet] + [Produces("application/json")] + public IEnumerable Get() + { + return GetEmployeesDeatils(); + } + + [HttpGet("{id}")] + [Produces("application/json")] + public Account Get(Guid id) + { + return GetEmployeesDeatils().Find(e => e.Id == id); + } + + [HttpPost] + [Produces("application/json")] + public Account Post([FromBody] Account employee) + { + // Write logic to insert employee data + return new Account(); + } + + private List GetEmployeesDeatils() + { + return new List() + { + new Account() + }; + } +} \ No newline at end of file diff --git a/vassago.csproj b/vassago.csproj index f51501f..958e03f 100644 --- a/vassago.csproj +++ b/vassago.csproj @@ -19,6 +19,9 @@ + + +