Beispiel #1
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_unitOfWork.Followings.GetFollowing(dto.FolloweeId, userId) != null)
            {
                return(BadRequest("Following already exists."));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
Beispiel #2
0
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            var userId = User.Identity.GetUserId();

            var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FolloweeId == followingDto.FolloweeId);

            if (exists)
            {
                return(BadRequest("Following already exist"));
            }
            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();
            return(Ok());
        }
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Relationships.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest("Already following!"));
            }

            var following = new Relationship()
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Relationships.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
Beispiel #5
0
        public HttpResponseMessage Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Following already exist."));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest("Following already exists."));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(x => x.FolloweeId == dto.FolloweeId && x.FollowerId == userId))
            {
                return(BadRequest("Follower Already Exist"));
            }
            var following = new Following()
            {
                FollowingId = Guid.NewGuid().ToString(),
                FollowerId  = User.Identity.GetUserId(),
                FolloweeId  = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
Beispiel #8
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();
            var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FolloweeId == dto.FolloweeId);

            if (exists)
            {
                return BadRequest("");
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };
            _context.Followings.Add(following);
            _context.SaveChanges();

            return Ok();
        }
        public IHttpActionResult Follow(FollowingDto followerDto)
        {
            var userId = User.Identity.GetUserId();

            if (_unitOfWork.Followings.GetFollowing(followerDto.FolloweeId, userId) != null)
            {
                return(Content(HttpStatusCode.BadRequest, ErrorMsg.FollowingAlreadyExists));
            }

            var follower = new Following
            {
                FolloweeId = followerDto.FolloweeId,
                FollowerId = userId
            };

            _unitOfWork.Followings.Add(follower);
            _unitOfWork.Complete();

            return(Ok());
        }
Beispiel #11
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var currentUser = User.Identity.GetUserId();

            if (_applicationDbContext.Followings.
                Any(f => f.FolloweeId == currentUser && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest());
            }

            var following = new Following
            {
                FolloweeId = dto.FolloweeId,
                FollowerId = currentUser
            };

            _applicationDbContext.Followings.Add(following);
            _applicationDbContext.SaveChanges();

            return(Ok());
        }
Beispiel #12
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userInDb  = User.Identity.GetUserId();
            var existInDb = _context.Followings.Any(f => f.ArtistId == dto.ArtistId && f.UserId == userInDb);

            if (existInDb)
            {
                return(BadRequest("Already following this Artist"));
            }

            var following = new Following
            {
                ArtistId = dto.ArtistId,
                UserId   = userInDb
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();
            var exists = _unitOfWork.Follow.IsFollowing(userId, dto.FolloweeId);

            if (exists)
            {
                return(BadRequest("Following already existis!"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitOfWork.Follow.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
        public IHttpActionResult AddFollower(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(f => f.ArtistId == dto.ArtistId && f.UserId == userId))
            {
                return(BadRequest("Already Following"));
            }

            var following = new Following
            {
                ArtistId = dto.ArtistId,
                UserId   = userId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();


            return(Ok());
        }
Beispiel #15
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId);

            if (following != null)
            {
                return(BadRequest("Zaten Takiptesiniz."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };
            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
        public ActionResult Follow(FollowingDto dto)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FollowerId == dto.FolloweeId);

            if (exists)
            {
                return(BadRequest("The attendance allready exists"));
            }

            var follow = new Following
            {
                FolloweeId = dto.FolloweeId,
                FollowerId = User.FindFirstValue(ClaimTypes.NameIdentifier)
            };

            _context.Followings.Add(follow);
            _context.SaveChanges();
            return(Ok());
        }
        public async Task <IHttpActionResult> Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();
            var exist  = await _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId) != null;

            if (exist)
            {
                return(BadRequest("Following already exist"));
            }

            var following = new Following
            {
                FolloweeId = userId,
                FollowerId = dto.FolloweeId
            };

            _unitOfWork.Followings.Add(following);
            await _unitOfWork.Complete();

            return(Ok());
        }
        public IHttpActionResult UnFollow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (context.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                var following = context.Followings
                                .Where(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId)

                                .FirstOrDefault();

                context.Followings.Remove(following);
                context.SaveChanges();
            }
            else
            {
                return(BadRequest("Following aready exists"));
            }

            return(Ok());
        }
Beispiel #19
0
        public IActionResult Follow(FollowingDto dto)
        {
            var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var following = _unitOfWork.Following.GetFollowing(userId, dto.FolloweeId);

            if (following != null)
            {
                return(BadRequest("Following already exists."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };
            _unitOfWork.Following.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            var userId = User.Identity.GetUserId();

            var exist = _context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == followingDto.ArtistId);

            if (exist)
            {
                return(BadRequest("You Are already following this artist"));
            }

            var follow = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.ArtistId
            };

            _context.Followings.Add(follow);
            _context.SaveChanges();

            return(Ok("Success"));
        }
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            if (db.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest("You two are already friends."));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId,
                DateTime   = DateTime.Now,
                Friends    = true
            };

            db.Followings.Add(following);
            db.SaveChanges();

            return(Ok());
        }
Beispiel #22
0
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            var userId = User.Identity.GetUserId();

            if (_dbContext.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == followingDto.FolloweeId))
            {
                return(BadRequest("Following already exists!"));
            }
            var folowing = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.FolloweeId
            };

            _dbContext.Followings.Add(folowing);
            _dbContext.SaveChanges();
            folowing = _dbContext.Followings
                       .Where(x => x.FolloweeId == followingDto.FolloweeId && x.FollowerId == userId)
                       .Include(x => x.Followee)
                       .Include(x => x.Follower).SingleOrDefault();
            return(Ok());
        }
Beispiel #23
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var       userId = User.Identity.GetUserId();
            Following follow = _unitofwork.Follows.AllMyFollowings(dto, userId);

            if (follow != null)
            {
                return(BadRequest("Following already exists"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitofwork.Follows.Add(following);
            _unitofwork.Complete();


            return(Ok());
        }
Beispiel #24
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            //if (_context.Followings.Any(f => f.FolloweeId == userId && f.FollowerId == dto.FollowerId))
            //    return BadRequest("Followings Already Exist");

            if (_unitOfWork.Followings.GetFollowing(userId, dto.FollowerId) != null)
            {
                return(BadRequest("Followings Already Exist"));
            }

            Following following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FollowerId
            };

            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();
            return(Ok());
        }
Beispiel #25
0
        private void FillData()
        {
            FollowingDto dto = new FollowingDto(); // User sa id=1 prati user-a sa id=2

            dto.ID         = 1;
            dto.FollowerID = 1;
            dto.FollowedID = 2;

            FollowingDto dto2 = new FollowingDto(); // User sa id=2 prati user-a sa id=3

            dto2.ID         = 2;
            dto2.FollowerID = 2;
            dto2.FollowedID = 3;

            FollowingDto dto3 = new FollowingDto(); // User sa id=3 prati user-a sa id=4

            dto3.ID         = 3;
            dto3.FollowerID = 3;
            dto3.FollowedID = 4;

            FollowingDto dto4 = new FollowingDto(); // User sa id=4 prati user-a sa id=5

            dto4.ID         = 4;
            dto4.FollowerID = 4;
            dto4.FollowedID = 5;

            FollowingDto dto5 = new FollowingDto(); // User sa id=2 prati user-a sa id=5

            dto5.ID         = 5;
            dto5.FollowerID = 2;
            dto5.FollowedID = 5;

            FollowingUsersList.Add(dto);
            FollowingUsersList.Add(dto2);
            FollowingUsersList.Add(dto3);
            FollowingUsersList.Add(dto4);
            FollowingUsersList.Add(dto5);
        }
Beispiel #26
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            var exists = _context.Followings.Any
                             (f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId);

            if (exists)
            {
                return(BadRequest("You are already following this Speaker"));
            }

            var following = new Following()
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
Beispiel #27
0
        public IHttpActionResult Follow(FollowingDto dto)
        {
            var userId = User.Identity.GetUserId();

            // Check if following already exists in db, before adding new
            var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId);

            if (following != null)
            {
                return(BadRequest("Following already exists."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
Beispiel #28
0
        public async Task <IActionResult> Follow([FromBody] FollowingDto dto)
        {
            var userId = _userManager.GetUserId(User);

            var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId);

            if (following != null)
            {
                return(BadRequest("Following already exists."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            await _unitOfWork.Followings.AddAsycn(following);

            await _unitOfWork.CompleteAsync();

            return(Ok());
        }
Beispiel #29
0
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            string followerId = User.Identity.GetUserId();

            Following follow = _unitOfWork.Followings.GetFollowing(followingDto.FolloweeId, followerId);

            if (follow != null)
            {
                return(BadRequest("Allready following."));
            }

            follow = new Following
            {
                FollowerId = followerId,
                FolloweeId = followingDto.FolloweeId
            };

            _unitOfWork.Followings.AddFollowing(follow);
            _unitOfWork.Complete();


            return(Ok());
        }
Beispiel #30
0
        public IHttpActionResult Follow(FollowingDto followingDto)
        {
            var userId = User.Identity.GetUserId();

            if (_dbContext.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == followingDto.FolloweeId))
            {
                return(BadRequest("Following already exists!"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.FolloweeId
            };



            _dbContext.Followings.Add(following);
            _dbContext.SaveChanges();

            //following = _dbContext.Followings
            //    .Where(x => x.FolloweeId == followingDto.FolloweeId && x.FollowerId == userId)
            //    .Include(x => x.Followee)
            //    .Include(x => x.Follower).SingleOrDefault();

            //var followingNotification = new FollowingNotification()
            //{
            //    Id = 0,
            //    Logger = following.Follower.Name + " following " + following.Followee.Name
            //};
            //_dbContext.FollowingNotifications.Add(followingNotification);
            //_dbContext.SaveChanges();


            return(Ok());
        }
Beispiel #31
0