예제 #1
0
        public async Task<IActionResult> ListTracked ()
        {
            ApplicationUser user = await GetCurrentUserAsync();

            var model = new TrackedMoviesViewModel();
            model.TrackedUserMovies = GetUserTrackedMovies(user);

            return View(model);
        }
        public async Task <IActionResult> Recommend(string movieUserId, string userId)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            var model = new TrackedMoviesViewModel();

            model.TrackedUserMovies = GetUserTrackedMovies(user);

            // get the user from the database
            var toUser = _context.Users.Where(u => u.Id == userId).SingleOrDefault();

            //create a record
            var recomemendation = new Recommendation()
            {
                ToUser      = toUser,
                MovieUserId = Convert.ToInt32(movieUserId)
            };


            _context.Add(recomemendation);
            await _context.SaveChangesAsync();

            return(RedirectToActionPermanent("ListTracked"));
        }