From e364b47c0fcbc9a5468300904bce74119e8bc6f6 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sun, 9 Jun 2024 17:37:09 -0400 Subject: [PATCH] details pages for channels added --- Program.cs | 2 +- WebInterface/Controllers/EmployeeControler.cs | 41 ------------------- .../Controllers/api/ChannelsControler.cs | 35 ++++++++++++++++ WebInterface/Views/Channels/Details.cshtml | 14 +++---- 4 files changed, 43 insertions(+), 49 deletions(-) delete mode 100644 WebInterface/Controllers/EmployeeControler.cs create mode 100644 WebInterface/Controllers/api/ChannelsControler.cs diff --git a/Program.cs b/Program.cs index 0cf43b7..469c76c 100644 --- a/Program.cs +++ b/Program.cs @@ -34,7 +34,7 @@ app.UseSwagger(); app.UseSwaggerUI(c => { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample API"); + c.SwaggerEndpoint("/swagger/v1/swagger.json", "api"); }); app.Run(); diff --git a/WebInterface/Controllers/EmployeeControler.cs b/WebInterface/Controllers/EmployeeControler.cs deleted file mode 100644 index 0d28c4c..0000000 --- a/WebInterface/Controllers/EmployeeControler.cs +++ /dev/null @@ -1,41 +0,0 @@ -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/WebInterface/Controllers/api/ChannelsControler.cs b/WebInterface/Controllers/api/ChannelsControler.cs new file mode 100644 index 0000000..784ffc5 --- /dev/null +++ b/WebInterface/Controllers/api/ChannelsControler.cs @@ -0,0 +1,35 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using vassago.Models; + +namespace vassago.Controllers.api; + +[Route("api/[controller]")] +[ApiController] +public class ChannelsController : ControllerBase +{ + private readonly ILogger _logger; + private readonly ChattingContext _db; + + public ChannelsController(ILogger logger, ChattingContext db) + { + _logger = logger; + _db = db; + } + + [HttpGet("{id}")] + [Produces("application/json")] + public Channel Get(Guid id) + { + return _db.Find(id); + } + + [HttpPost] + [Produces("application/json")] + public Channel Post([FromBody] Channel channel) + { + // Write logic to insert employee data + return new Channel(); + } +} \ No newline at end of file diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index 2bac39f..7c35fe5 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -14,11 +14,11 @@ Lewdness Filter Level - @Model.LewdnessFilterLevel + @(Model.LewdnessFilterLevel?.ToString() ?? "inherited") Links Allowed - @Model.LinksAllowed + @(Model.LinksAllowed?.ToString() ?? "unknown") Lineage summary @@ -30,11 +30,11 @@ max message length - @Model.MaxTextChars + @(Model.MaxTextChars?.ToString() ?? "inherited") Meanness Filter Level - @Model.MeannessFilterLevel + @(Model.MeannessFilterLevel?.ToString() ?? "inherited") Messages (count) @@ -46,15 +46,15 @@ Reactions Possible - @Model.ReactionsPossible + @(Model.ReactionsPossible?.ToString() ?? "inherited") Sub Channels - @Model.SubChannels + @(Model.SubChannels?.Count ?? 0) Users - @Model.Users + @(Model.Users?.Count ?? 0)