示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RatingValue")] Rating rating)
        {
            if (id != rating.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rating);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RatingExists(rating.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rating));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,UserName")] Writer writer)
        {
            if (id != writer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(writer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WriterExists(writer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(writer));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,ReleaseDate,Country,Description,Genre,RatingId,WriterId")] Movie movie)
        {
            if (id != movie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RatingId"] = new SelectList(_context.Rating, "Id", "RatingValue", movie.RatingId);
            ViewData["WriterId"] = new SelectList(_context.Writer, "Id", "FirstName", movie.WriterId);
            return(View(movie));
        }