Пример #1
0
        public async Task SendNotifications(int FotoId, NotificationType type, string currentUserId)
        {
            int notificationType = 1;

            if (type.Equals(NotificationType.LIKE))
            {
                try
                {
                    var count = await _likeRepository.GetLikeCount(FotoId);

                    var foto = await _fotoRepository.GetFotoById(FotoId);

                    //var currentUser = await _userRepository.GetCurrentUser(_contextAccessor.HttpContext.User);
                    var notification = new Notification
                    {
                        ApplicationUserIdSend = currentUserId,
                        ApplicationUserId     = foto.ApplicationUserId,
                        NotificationType      = notificationType
                    };

                    //await _notificationRepository.SaveNotification(notification);

                    var likeNotification = new
                    {
                        FotoId,
                        count,
                        notificationType
                    };
                    await Clients.All.SendAsync("Notifications", likeNotification);
                }
                catch (Exception e)
                {
                    e.ToString();
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> GetFoto(int id)
        {
            var foto = await _fotoRepository.GetFotoById(id);

            return(Json(foto));
        }