using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Logging; using AyaNova.Models; using AyaNova.Api.ControllerHelpers; using AyaNova.Biz; namespace AyaNova.Api.Controllers { [ApiController] [ApiVersion("8.0")] [Route("api/v{version:apiVersion}/notify")] [Produces("application/json")] [Authorize] public class NotifyController : ControllerBase { private readonly AyContext ct; private readonly ILogger log; private readonly ApiServerState serverState; /// /// ctor /// /// /// /// public NotifyController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) { ct = dbcontext; log = logger; serverState = apiServerState; } /// /// Pre-login route to confirm server is available /// /// [AllowAnonymous] [HttpGet("hello")] public ActionResult GetPreLoginPing() { //note: this route is called by the client to determine if it should display trial login ui //and to see if the server is contactable if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return Ok(ApiOkResponse.Response(!AyaNova.Core.License.ActiveKey.TrialLicense)); } /// /// Get count of new notifications waiting /// /// [HttpGet("new-count")] public ActionResult GetNewCount() { //STUB: https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3783 if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return Ok(ApiOkResponse.Response(69)); } //TODO: See new count case for gist of it //todo: see the core-notification.txt spec doc for details and //todo: see seemingly countless Notification related cases for details :) //------------ }//eoc }//eons