using CodeLiturgy.Data.Auth.Context.Users; using CodeLiturgy.Domain; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace CodeLiturgy.Views.Controllers { [ApiController] [Authorize] public class EnvironmentController : ControllerBase { private ApplicationUserManager _userManager; private ILogger _logger; private readonly SiteDbContext _siteDbContext; public EnvironmentController(ApplicationUserManager userManager, ILogger logger, SiteDbContext siteDbContext) { _logger = logger; _userManager = userManager; _siteDbContext = siteDbContext; } [HttpGet("/api/environments")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] public ActionResult GetEnvironments( int skip = 0, int take = 50, int orderDir = 1) { var (success, sites) = _siteDbContext.GetEnvironments(skip, take, orderDir); if (!success) return new NotFoundResult(); return Ok(sites); } /// /// Get Country by Id /// /// ISO 3166-1 countryId numeric code /// [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [HttpGet("/api/environments/{environmentId}", Name = nameof(GetEnvironmentById))] public ActionResult GetEnvironmentById(string siteId) { var (success, environment) = _siteDbContext.GetOneSiteById(siteId); if (success) { return Ok(environment); } return new NotFoundResult(); } } }