Example #1
0
        public IHttpActionResult Follow(InterestDto dto)
        {
            var followerId = User.Identity.GetUserId();

            if (_interestRepository.IsInterested(dto.IdeaId, followerId))
            {
                return(BadRequest("You are already interested in this Idea"));
            }

            _interestRepository.Add(dto.IdeaId, followerId);

            return(Ok());
        }
Example #2
0
        // GET: Ideas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var idea = _ideaRepository.GetAnIdea((int)id);

            if (idea == null)
            {
                return(HttpNotFound());
            }
            var userId    = User.Identity.GetUserId();
            var viewModel = new IdeaDetailsViewModel()
            {
                Idea             = idea,
                VisitedByFounder = (userId == idea.FounderId),
                IsInterested     = _interestRepository.IsInterested((int)id, userId)
            };

            return(View("Details", viewModel));
        }