Пример #1
0
        public async Task <string> AddFollowingsAsync(AddFollowerRequest request)
        {
            var currentUser = Feature.CurrentUser(_httpContextAccessor, userRepository);

            foreach (var item in request.Followers)
            {
                var user = await userRepository.GetByIdAsync(ObjectId.Parse(item));

                if (user != null)
                {
                    var filter         = Builders <Follow> .Filter;
                    var finder         = filter.Eq(FromId, currentUser.OId) & filter.Eq(ToId, item);
                    var existFollowing = await followRepository.FindAsync(finder);

                    if (existFollowing != null)
                    {
                        return(UserFollowAlready);
                    }

                    var follow = new Follow()
                    {
                        FromId     = currentUser.OId,
                        ToId       = item,
                        FollowDate = DateTime.Now
                    };

                    await followRepository.AddAsync(follow);

                    var notificationDetail = new Noftication()
                    {
                        AuthorId        = currentUser.OId,
                        OwnerId         = item,
                        ObjectId        = currentUser.OId,
                        ObjectThumbnail = string.Empty
                    };

                    await fcmRepository.PushNotify(item, notificationDetail, NotificationContent.FollowNotification);
                }
            }
            return(FollowSuccess);
        }
Пример #2
0
        public async Task <IActionResult> AddFollowings([FromBody] AddFollowerRequest request)
        {
            var data = await userService.AddFollowingsAsync(request);

            return(Ok(new ApiOkResponse(data)));
        }
 public async Task <IActionResult> UploadFile([FromBody] AddFollowerRequest request)
 {
     throw new NotImplementedException();
 }