BC.Web.Controllers.GamesController.SendNotification C# (CSharp) Méthode

SendNotification() private méthode

private SendNotification ( int gameId, string userId, string type, string message ) : void
gameId int
userId string
type string
message string
Résultat void
        private void SendNotification(int gameId, string userId, string type, string message)
        {
            var receiver = this.data.Users.Find(userId);
            var game = this.data.Games.All()
                .Where(a => a.Id == gameId)
                .FirstOrDefault();

            if (game == null)
            {
                throw new ArgumentException("Game do not exists");
            }

            var newNotification = new Notification
            {
                Message = message,
                DateCreated = DateTime.Now,
                Type = type,
                State = NotificationState.Unread,
                GameId = gameId,
                Game = game,
                UserId = userId,
                User = receiver
            };

            this.data.Notifications.Add(newNotification);
            receiver.Notifications.Add(newNotification);
            this.data.SaveChanges();
        }
    }