Exemple #1
0
        public IHttpActionResult Follow(FollowingArtistDto dto)
        {
            try
            {
                var userId = User.Identity.GetUserId();

                if (_context.Followers.Any(f => f.FollowerId == userId && f.FolloweeId == dto.ArtistId))
                {
                    return(BadRequest("Już śledzisz tego wykonawcę!"));
                }

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

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

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest("Obserwowanie nie powiodło się."));
            }
        }
Exemple #2
0
        public ActionResult Following()
        {
            var             UserId    = User.Identity.GetUserId();
            var             Artist    = _context.Follow.Where(f => f.FollowerId == UserId).Select(f => f.Followee).ToList();
            FollowingArtist MyArtists = new FollowingArtist();

            MyArtists.FollowedArtist = Artist;
            return(View(MyArtists));
        }