Exemple #1
0
 public async Task SendNotification(NotificationsSenderViewModel viewModel)
 {
     if (!String.IsNullOrEmpty(viewModel.Notification))
     {
         await _serverSentEventsService.SendEventAsync(new ServerSentEvent
         {
             Type = viewModel.Alert ? "alert" : null,
             Data = new List <string>(viewModel.Notification.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None))
         });
     }
 }
        public async Task <IActionResult> Sender(NotificationsSenderViewModel viewModel)
        {
            if (!String.IsNullOrEmpty(viewModel.Notification))
            {
                await _notificationsService.SendNotificationAsync(viewModel.Notification, viewModel.Alert);
            }

            ModelState.Clear();

            return(View("Sender", new NotificationsSenderViewModel()));
        }
        public async Task <IActionResult> Sender(NotificationsSenderViewModel viewModel)
        {
            if (!String.IsNullOrEmpty(viewModel.Notification))
            {
                await _serverSentEventsService.SendEventAsync(new ServerSentEvent
                {
                    Type = viewModel.Alert ? "alert" : null,
                    Data = new List <string>(viewModel.Notification.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None))
                });
            }

            ModelState.Clear();

            return(View("Sender", new NotificationsSenderViewModel()));
        }
        public async Task <IActionResult> Sender(NotificationsSenderViewModel viewModel)
        {
            if (!String.IsNullOrEmpty(viewModel.Notification))
            {
                var redis = ConnectionMultiplexer.Connect("redis_image:6379");
                var db    = redis.GetDatabase();
                var y     = db.StringGet("user_" + viewModel.UserId);
                var z     = JsonConvert.DeserializeObject <User>(y.ToString());
                viewModel.Name = z.Login;
                string notification = z.Login + " dodał nową publikację. Naciśnij to powiadomienie by do niej przejść.";
                string href         = "http://localhost:8080/Bibliography/ShowPosition?link=" + viewModel.Href.Replace("localhost:8081", "web2");
                await _notificationsService.SendNotificationAsync(notification, viewModel.Alert, href, z.Id);
            }

            ModelState.Clear();

            return(RedirectToAction("Index", "Home"));
        }