This commit is contained in:
2021-06-18 19:26:39 +00:00
parent 5fd4362143
commit 0e04bb90c9

View File

@@ -9,6 +9,7 @@ using AyaNova.Biz;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System;
namespace AyaNova.Api.Controllers
{
@@ -168,15 +169,18 @@ namespace AyaNova.Api.Controllers
List<NotifySubscriptionRecord> ret = new List<NotifySubscriptionRecord>();
foreach (var s in subs)
{
ret.Add(new NotifySubscriptionRecord(s.Id, s.UserId, s.EventType, s.AyaType, s.DeliveryMethod, s.DeliveryAddress, s.Tags, await GetInfo(s, ct)));
ret.Add(new NotifySubscriptionRecord(s.Id, s.UserId, s.EventType, s.AyaType, s.DeliveryMethod, s.DeliveryAddress, s.Tags, await GetStatusName(s, ct), s.AgeValue, s.DecValue));
}
return Ok(ApiOkResponse.Response(ret));
}
private record NotifySubscriptionRecord(long id, long userid, NotifyEventType eventType, AyaType AyaType, NotifyDeliveryMethod deliveryMethod, string deliveryAddress, List<string> tags, string info);
private record NotifySubscriptionRecord(
long id, long userid, NotifyEventType eventType, AyaType AyaType,
NotifyDeliveryMethod deliveryMethod, string deliveryAddress, List<string> tags, string status, TimeSpan ageValue, decimal decValue
);
//Provide extra info about subscription
private static async Task<string> GetInfo(NotifySubscription s, AyContext ct)
private static async Task<string> GetStatusName(NotifySubscription s, AyContext ct)
{
switch (s.EventType)
{
@@ -184,9 +188,11 @@ namespace AyaNova.Api.Controllers
case NotifyEventType.WorkorderStatusChange:
//add status text to info
return await ct.WorkOrderStatus.AsNoTracking().Where(x => x.Id == s.IdValue).Select(x => x.Name).FirstOrDefaultAsync();
default:
return string.Empty;
case NotifyEventType.QuoteStatusAge:
case NotifyEventType.QuoteStatusChange:
throw new System.NotImplementedException("TODO: quote status events in notifysubscriptioncontroller::getStatusName");
}
return string.Empty;
}
//------------