Example #1
0
        public async Task AddAlertAsync(IAlert alert)
        {
            if (alert is ISystemAlert)
            {
                _authDbContext.SystemSecurityAlerts.Add(
                    new SystemSecurityAlert
                {
                    AlertType     = alert.AlertType,
                    KeyValueStore = alert.GetDictionary(),
                }
                    );
            }

            if (alert is IUserAlert)
            {
                _authDbContext.UserSecurityAlerts.Add(
                    new UserSecurityAlert
                {
                    AlertType     = alert.AlertType,
                    KeyValueStore = alert.GetDictionary(),
                    Recipient     = ((IUserAlert)alert).TargetUser,
                }
                    );
            }

            await _authDbContext.SaveChangesAsync();
        }