This commit is contained in:
2020-07-27 21:52:00 +00:00
parent 095732da1b
commit 7b67bdb2e2
3 changed files with 50 additions and 2 deletions

View File

@@ -79,7 +79,16 @@ namespace AyaNova.Biz
var UserName = await ct.User.Where(z => z.Id == userId).Select(z => z.Name).FirstOrDefaultAsync();
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = 0, Name = UserName };
//if they don't have a regular inapp subscription create one now
var defaultsub = await ct.NotifySubscription.FirstOrDefaultAsync(z => z.EventType == NotifyEventType.GeneralNotification && z.UserId == userId && z.DeliveryMethod == NotifyDeliveryMethod.App);
if (defaultsub == null)
{
defaultsub = new NotifySubscription() { UserId = userId, EventType = NotifyEventType.GeneralNotification, DeliveryMethod = NotifyDeliveryMethod.App };
await ct.NotifySubscription.AddAsync(defaultsub);
await ct.SaveChangesAsync();
}
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = defaultsub.Id, Name = UserName };
await ct.NotifyEvent.AddAsync(n);
await ct.SaveChangesAsync();
return;