예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Genre,Rating,Description")] Show show)
        {
            if (id != show.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(show);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShowExists(show.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(show));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,ShowName,Season,EpisodeNumber,EpisodeName,Description,BestCharacter,HumorRating,StoryRating,OverallGrade")] Episodes episodes)
        {
            if (id != episodes.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    episodes.OverallGrade = episodes.HumorRating + episodes.StoryRating;
                    _context.Update(episodes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EpisodesExists(episodes.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(episodes));
        }