コード例 #1
0
        public async Task <IActionResult> Create([Bind("GenreName,Description")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genre);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(genre));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Name,Year,Type,MovieId,PersonId,Result")] MovieAward movieAward)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieAward);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["Name"]     = new SelectList(_context.AwardType, "Name", "Name", movieAward.Name);
            ViewData["MovieId"]  = new SelectList(_context.Movie, "MovieId", "Title", movieAward.MovieId);
            ViewData["PersonId"] = new SelectList(_context.Person, "PersonId", "Firstname", movieAward.PersonId);
            return(View(movieAward));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("MovieId,Title,Duration,Description,PublicationYear,CoverImage,PreviousPart,Price,Url")] Movie movie, List <IFormFile> files)
        {
            var t = files;

            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                _cache.Remove("LatestMovies");
                return(RedirectToAction("Edit", new { id = movie.MovieId }));
            }

            return(RedirectToAction("Edit", new { id = movie.MovieId }));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("PersonId,Lastname,Firstname,Gender")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                if (Request.Query.ContainsKey("ref"))
                {
                    return(RedirectToAction("Edit", "Movie", new { id = Request.Query["ref"], editType = Request.Query["editType"], person = person.PersonId }));
                }

                return(RedirectToAction("Index"));
            }



            return(View(person));
        }