This commit is contained in:
2020-07-10 18:09:01 +00:00
parent 671ab5cf2b
commit 1d529b1e73
3 changed files with 9 additions and 9 deletions

View File

@@ -57,14 +57,12 @@ namespace AyaNova.Api.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet("new-count")] [HttpGet("new-count")]
public ActionResult GetNewCount() public async Task<IActionResult> GetNewCount()
{ {
//STUB: https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3783
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
System.Random rnd = new System.Random(); var UserId = UserIdFromContext.Id(HttpContext.Items);
int RandomNewCount = rnd.Next(20); return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
return Ok(ApiOkResponse.Response(RandomNewCount));
} }

View File

@@ -14,6 +14,8 @@ namespace AyaNova.Models
public long Id { get; set; } public long Id { get; set; }
public uint Concurrency { get; set; } public uint Concurrency { get; set; }
[Required]
public long UserId { get; set; }
[Required] [Required]
public DateTime Created { get; set; } public DateTime Created { get; set; }
public AyaType? AyaType { get; set; } public AyaType? AyaType { get; set; }
@@ -24,12 +26,12 @@ namespace AyaNova.Models
public long SubscriptionId { get; set; } public long SubscriptionId { get; set; }
public string Message { get; set; } public string Message { get; set; }
[Required] [Required]
public bool Fetched {get;set;} public bool Fetched { get; set; }
public Notification() public Notification()
{ {
Created = DateTime.UtcNow; Created = DateTime.UtcNow;
Fetched=false; Fetched = false;
} }
}//eoc }//eoc

View File

@@ -690,7 +690,7 @@ $BODY$;
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " + await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " +
"ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, message text)"); "ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, message text)");
await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, ayatype integer, objectid bigint, eventtype integer not null, " + await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid bigint not null, created timestamp not null, ayatype integer, objectid bigint, eventtype integer not null, " +
"subscriptionid bigint not null, message text, fetched bool not null)"); "subscriptionid bigint not null, message text, fetched bool not null)");
await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed timestamp not null, ayatype integer, objectid bigint, " + await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed timestamp not null, ayatype integer, objectid bigint, " +