/// <summary> /// Synchronization users add to friends notifications /// </summary> public void SynchronizeAddFriendNotifications(FriendReceiveModel friendReceiveModel) { var notification = new NotificationReceiveModel() { FromUserId = friendReceiveModel.UserId, ToUserId = friendReceiveModel.FriendId }; if (_mainLogic.GetNotification(notification) == null) { _logger.Info($"Sync notification for user {friendReceiveModel.FriendId} from user {friendReceiveModel.UserId}"); notification.IsAccepted = false; notification.Message = "Пользователь " + $"{(_mainLogic.GetUser(new UserReceiveModel() { Id = notification.FromUserId }).JsonData as UserResponseModel).UserName}" + " хочет добавить вас в друзья"; _mainLogic.AddNotification(notification); var endClient = _connectedClients.FirstOrDefault(c => c.Id == notification.ToUserId); if (endClient != null) { Task.Run(() => { var notificationDb = _mainLogic.GetNotification(notification); endClient.SendMessage(_encoder.Encryption(_jsonStringSerializer.Serialize(new OperationResultInfo() { ErrorInfo = string.Empty, OperationResult = OperationsResults.Successfully, ToListener = ListenerType.NotificationListListener, JsonData = _jsonStringSerializer.Serialize(notificationDb) }))); //endClient.SendMessage(_jsonStringSerializer.Serialize(new OperationResultInfo() //{ // ErrorInfo = string.Empty, // OperationResult = OperationsResults.Successfully, // ToListener = ListenerType.NotificationListListener, // JsonData = _jsonStringSerializer.Serialize(notificationDb) //})); }); } } }