11using System . Linq ;
2+ using System . Threading . Tasks ;
3+ using Dns . Db . Models . EntityFramework ;
4+ using Dns . Db . Repositories ;
25using Dns . Services ;
36using Microsoft . AspNetCore . Http ;
47using Microsoft . AspNetCore . Mvc ;
@@ -7,9 +10,14 @@ namespace Dns.Cli.Controllers;
710
811#pragma warning disable CS9113
912
13+ /// <summary>
14+ ///
15+ /// </summary>
16+ /// <param name="dnsService"></param>
17+ /// <param name="dnsServer"></param>
1018[ ApiController ]
1119[ Route ( "dns/" ) ]
12- public class DnsController ( IDnsService dnsService , IDnsServer dnsServer ) : ControllerBase
20+ public class DnsController ( IDnsService dnsService , IDnsServer dnsServer , IZoneRepository zoneRepository ) : ControllerBase
1321{
1422 /// <summary>
1523 /// Dump Resolver data
@@ -21,6 +29,31 @@ public class DnsController(IDnsService dnsService, IDnsServer dnsServer) : Contr
2129 [ HttpGet ( "resolvers" ) ]
2230 public IActionResult ? GetDnsResolverData ( )
2331 => Ok ( dnsService . Resolvers . Select ( s => s . GetObject ( ) ) ) ;
32+
33+ /// <summary>
34+ /// Get database zones
35+ /// </summary>
36+ /// <returns>html</returns>
37+ [ ProducesResponseType ( StatusCodes . Status200OK ) ]
38+ [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
39+ [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
40+ [ HttpGet ( "zones" ) ]
41+ public async Task < IActionResult ? > GetZones ( )
42+ => Ok ( await zoneRepository . GetZones ( ) . ConfigureAwait ( false ) ) ;
43+
44+ /// <summary>
45+ /// Get database zones
46+ /// </summary>
47+ /// <returns>html</returns>
48+ [ ProducesResponseType ( StatusCodes . Status200OK ) ]
49+ [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
50+ [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
51+ [ HttpPut ( "zones" ) ]
52+ public async Task < IActionResult ? > AddZone ( [ FromBody ] Zone zone )
53+ {
54+ await zoneRepository . AddZone ( zone ) . ConfigureAwait ( false ) ;
55+ return Created ( ) ;
56+ }
2457}
2558
2659#pragma warning restore CS9113
0 commit comments