public IActionResult NotifyTeam([FromBody] NotificationPayload payload)
        {
            // Auth: only orgadmins
            if (!IsOrganizationAdmin())
            {
                throw new UnauthorizedAccessException();
            }

            return(DbOperation(c =>
            {
                Audit.Information(this, "{0}: Notifications.NotifyTeam: {1} | {2}", GetUserId(), payload.Title, payload.Message);

                int notificationsNumber = NotifyTeam(c, null, payload.Id, payload.Title, payload.Message);

                var teamPlayers = c.Query <Player>("SELECT tp.idplayer, p.id, p.iduser FROM teamplayers tp JOIN players p ON tp.idPlayer = p.id WHERE idTeam = @id", new { id = payload.Id });

                foreach (var player in teamPlayers)
                {
                    c.Insert(new Notification {
                        IdCreator = GetUserId(), IdRcptUser = player.IdUser, Status = (int)NotificationStatus.Unread, Text2 = payload.Title, Text = payload.Message, TimeStamp = DateTime.Now
                    });
                }

                return notificationsNumber;
            }));
        }
        public IActionResult NotifyUser([FromBody] NotificationPayload payload)
        {
            // Auth: only orgadmins
            if (!IsOrganizationAdmin())
            {
                throw new UnauthorizedAccessException();
            }

            return(DbOperation(c =>
            {
                Audit.Information(this, "{0}: Notifications.NotifyUser: {1} | {2}", GetUserId(), payload.Title, payload.Message);

                int notificationsNumber = NotifyUser(c, null, payload.Id, payload.Title, payload.Message);

                c.Insert(new Notification {
                    IdCreator = GetUserId(), IdRcptUser = payload.Id, Status = (int)NotificationStatus.Unread, Text2 = payload.Title, Text = payload.Message, TimeStamp = DateTime.Now
                });

                return notificationsNumber;
            }));
        }