Beispiel #1
0
        public ActionResult FollowUser(UserFollowDTO model)
        {
            try
            {
                var currentUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                if (!_userService.Exists(model.FollowingId) && !_userService.Exists(model.FollowersId))
                {
                    return(NotFound("Kullanıcı yok"));
                }
                //önceden takip ediyormuyum?

                if (_followService.AmIFollowing(model.FollowersId, model.FollowingId))
                {
                    return(BadRequest("Zaten Takip ediyorsun"));
                }
                _followService.Add(new Follow {
                    Id = Guid.NewGuid(), FollowDate = DateTime.Now, FollowersId = model.FollowersId, FollowingId = model.FollowingId
                });
                _notificationService.Create(new Notification
                {
                    Id = Guid.NewGuid(), UserId = Guid.Parse(currentUserId), TriggerUserId = model.FollowersId
                });
                _hubContext.Clients.All.SendAsync("NotificationGuncelle");

                //  _hubContext.Clients.User("P0m3D-Y_Ra5VZBd3ypUR5g").SendAsync("SendNotification", Guid.Parse("4bcbbcbf-d75f-4c0f-821c-2a833f800ff4"), Guid.Parse("6f6dc2ff-b828-41d1-a27b-a993e944ce7e"), "asdsad");

                return(StatusCode(200, "Başarılı"));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
        public async Task <IActionResult> Add([FromRoute] string nameUserFollower, [FromRoute] int idUserFollowing)
        {
            Response result = await _followService.Add(nameUserFollower, idUserFollowing);

            return(Ok(result));
        }