Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Country,QuestionnaireId,IdentityUserId")] MovieWatcher movieWatcher)
        {
            if (id != movieWatcher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieWatcher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieWatcherExists(movieWatcher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdentityUserId"]  = new SelectList(_context.Users, "Id", "Id", movieWatcher.IdentityUserId);
            ViewData["QuestionnaireId"] = new SelectList(_context.Questionnaires, "Id", "Id", movieWatcher.QuestionnaireId);
            return(View(movieWatcher));
        }
Exemplo n.º 2
0
        // GET: MovieWatchers/Create
        public IActionResult Create()
        {
            MovieWatcher movieWatcher = new MovieWatcher();

            //ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id");
            //ViewData["QuestionnaireId"] = new SelectList(_context.Questionnaires, "Id", "Id");
            return(View(movieWatcher));
        }
Exemplo n.º 3
0
        // GET: MovieWatchers/Details/5
        public IActionResult Details(MovieWatcher movieWatcher)
        {
            if (movieWatcher == null)
            {
                return(NotFound());
            }

            return(View(movieWatcher));
        }
Exemplo n.º 4
0
        public IActionResult Create(MovieWatcher movieWatcher)
        {
            if (ModelState.IsValid)
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                movieWatcher.IdentityUserId = userId;
                _context.Add(movieWatcher);
                _context.SaveChanges();
                return(RedirectToAction("Create", "Questionnaires"));
            }


            return(RedirectToAction("Details"));
        }