This commit is contained in:
@@ -343,6 +343,39 @@ namespace AyaNova.Biz
|
|||||||
//ServiceBankDepleted
|
//ServiceBankDepleted
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AyaType.User:
|
||||||
|
//This one's a little different, if user has had roles changed, then pre-existing subs may not be allowed anymore
|
||||||
|
//Remove any notification subscriptions user doesn't have rights to:
|
||||||
|
if (((User)originalObject).Roles != ((User)newObject).Roles)
|
||||||
|
{
|
||||||
|
var DeleteList = new List<long>();
|
||||||
|
var NewRoles = ((User)newObject).Roles;
|
||||||
|
//iterate subs and remove any user shouldn't have
|
||||||
|
var userSubs = await ct.NotifySubscription.Where(z => z.UserId == newObject.Id).ToListAsync();
|
||||||
|
foreach (var sub in userSubs)
|
||||||
|
{
|
||||||
|
if (sub.AyaType != AyaType.NoType)
|
||||||
|
{
|
||||||
|
//check if user has rights to it or not still
|
||||||
|
//must have read rights to be valid
|
||||||
|
if (!AyaNova.Api.ControllerHelpers.Authorized.HasAnyRole(NewRoles, sub.AyaType))
|
||||||
|
{
|
||||||
|
//no rights whatsoever, so delete it
|
||||||
|
DeleteList.Add(sub.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (DeleteList.Count > 0)
|
||||||
|
{
|
||||||
|
var NSB = NotifySubscriptionBiz.GetBiz(ct);
|
||||||
|
foreach (var l in DeleteList)
|
||||||
|
{
|
||||||
|
await NSB.DeleteAsync(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace AyaNova.Biz
|
|||||||
internal async Task<NotifySubscription> PutAsync(NotifySubscription putObject)
|
internal async Task<NotifySubscription> PutAsync(NotifySubscription putObject)
|
||||||
{
|
{
|
||||||
//TODO: Must remove all prior events and replace them
|
//TODO: Must remove all prior events and replace them
|
||||||
|
|
||||||
NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == putObject.Id);
|
NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == putObject.Id);
|
||||||
if (dbObject == null)
|
if (dbObject == null)
|
||||||
{
|
{
|
||||||
@@ -136,8 +136,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> DeleteAsync(long id)
|
internal async Task<bool> DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException("NotifySubscriptionBiz::DeleteAsync NOT IMPLEMENTED YET");
|
|
||||||
//needs to delete notifyevent and also notifications records
|
|
||||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -157,6 +156,7 @@ namespace AyaNova.Biz
|
|||||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||||
//await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
//await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||||
//TODO: DELETE RELATED RECORDS HERE
|
//TODO: DELETE RELATED RECORDS HERE
|
||||||
|
|
||||||
//all good do the commit
|
//all good do the commit
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
@@ -171,18 +171,23 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//VALIDATION
|
//VALIDATION
|
||||||
//
|
//
|
||||||
private async Task ValidateAsync(NotifySubscription proposedObj)
|
private async Task ValidateAsync(NotifySubscription proposedObj)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//###############################################################################
|
||||||
//todo: validate subscription is valid
|
//todo: validate subscription is valid
|
||||||
//perhaps check if customer type user doesn't have non customer notification etc
|
//perhaps check if customer type user doesn't have non customer notification etc
|
||||||
|
|
||||||
|
//todo: notifysubscriptionbiz Check for duplicate before accepting new / edit in validator
|
||||||
|
//DISALLOW entirely duplicate notifications (down to email address)
|
||||||
|
//USE NAME DUPE CHECK PATTERN BELOW
|
||||||
|
//###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//NOTE: In DB schema only name and serial are not nullable
|
//NOTE: In DB schema only name and serial are not nullable
|
||||||
|
|
||||||
|
|||||||
@@ -299,6 +299,8 @@ namespace AyaNova.Biz
|
|||||||
await SearchIndexAsync(dbObject, false);
|
await SearchIndexAsync(dbObject, false);
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj);
|
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj);
|
||||||
|
|
||||||
|
|
||||||
return dbObject;
|
return dbObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user