コード例 #1
0
        public async Task <IActionResult> Create([Bind("Description,University,Id,Name,Lastname,Phone,Genre,Email,Birthdate")] Speaker speaker)
        {
            if (ModelState.IsValid)
            {
                _context.Add(speaker);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(speaker));
        }
コード例 #2
0
        public async Task <IActionResult> Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ID,date,name,isHoliday,holidayCategory,description")] Calendar calendar)
        {
            if (ModelState.IsValid)
            {
                _context.Add(calendar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(calendar));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] Todo todo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(todo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(todo));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price,Rating")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie)); //this line is hit if there are validation errors, so the same screen will be re-dispalyed.
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,Forename,Surname,DOB")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,Nama,Jadwal")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                _context.Add(booking);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(booking));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("ID,Titulo,DataLancamento,Genero,Preco,Avaliacao")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
コード例 #9
0
ファイル: SubjectsController.cs プロジェクト: Mazhar30/Movies
        public async Task <IActionResult> Create([Bind("Id,sub,mark")] Subjects subjects)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subjects);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(subjects));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("Id,Title")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Director director)
        {
            if (ModelState.IsValid)
            {
                _context.Add(director);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(director));
        }
コード例 #12
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,DOB,Email")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
コード例 #13
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Title,Genre")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
コード例 #14
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price,Rating")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
コード例 #15
0
        public async Task <IActionResult> Create([Bind("Id,Name,IsDone,Priority")] ToDo toDo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(toDo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(toDo));
        }
コード例 #16
0
        public async Task <IActionResult> Create([Bind("Id,Name,Code")] Language language)
        {
            if (ModelState.IsValid)
            {
                _context.Add(language);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(language));
        }
コード例 #17
0
        public async Task <IActionResult> Create([Bind("CommentsToDoId,Name,Content,ToDoId")] CommentsToDo commentsToDo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(commentsToDo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ToDoId"] = new SelectList(_context.ToDo, "ToDoId", "ToDoId", commentsToDo.ToDoId);
            return(View(commentsToDo));
        }
コード例 #18
0
        public async Task <IActionResult> SendReview([Bind("Id,Name,Review,ReviewDate")] Comments comments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comments);
                comments.ReviewDate = DateTime.Now;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details)));
            }
            return(View(comments));
        }
コード例 #19
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price,Stock,Director,Description,ImageURL")] Movie movie)
        {
            // PERFORMS SERVER-SIDE VALIDATION - confirmed working with javascript disabled on client.
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
コード例 #20
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price,Rating,DiretorID")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DiretorID"] = new SelectList(_context.Diretor, "ID", "Name", movie.DiretorID);
            return(View(movie));
        }
コード例 #21
0
        public async Task <IActionResult> Create([Bind("CourseID,Title,Credits,DepartmentID")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PopulateDepartmentsDropDownList(course.DepartmentID);
            return(View(course));
        }
コード例 #22
0
        public async Task <IActionResult> Create([Bind("s_code,p_name,SellDate,s_amount,Price,Rating")] Sell sell)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sell);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["p_name"] = new SelectList(_context.Product, "p_name", "p_name", sell.p_name);
            return(View(sell));
        }
コード例 #23
0
        public async Task <IActionResult> Create([Bind("UserID,UserName,UserReview,ReviewDate")] User user)
        {
            if (ModelState.IsValid)
            {
                user.UserID = Guid.NewGuid();
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
コード例 #24
0
        public async Task <IActionResult> Create([Bind("Id,Name,Author,ISBN")] Book book)
        {
            if (ModelState.IsValid)
            {
                await _context.AddAsync(book);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
コード例 #25
0
ファイル: MoviesController.cs プロジェクト: cc240/MvcMovie
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> CreateMovie(Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                var result = await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(Json(result > 0 ? new { code = 0, msg = "添加成功" } : new { code = 1, msg = "网络打瞌睡了!" }));
            }
            return(Json(new { code = 0, msg = "数据验证失败" }));
        }
コード例 #26
0
ファイル: MoviesController.cs プロジェクト: Hilkias/MvcMovie
        public async Task <IActionResult> Create([Bind("MovieId,Title,ReleaseDate,GenreId,Price,Image")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["GenreId"] = new SelectList(_context.Genre, "GenreId", "GenreId", movie.GenreId);
            return(View(movie));
        }
コード例 #27
0
        public async Task <IActionResult> CreateReview([Bind("Id,IdMovie,Reviewer,Text")] Review review)
        {
            review.ReviewDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #28
0
        public async Task <IActionResult> Create([Bind("ReviewId,Title,Content,MovieId")] Review review)
        {
            if (ModelState.IsValid)
            {
                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieId"] = new SelectList(_context.Movie, "Id", "Title", review.MovieId);
            return(View(review));
        }
コード例 #29
0
        public async Task <IActionResult> Create(int id, [Bind("ReviewsID,Reviewer,Review,MovieID")] Reviews reviews)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reviews);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Movies", new { ID = reviews.MovieID }));
            }
            ViewData["MovieID"] = new SelectList(_context.Movie, "ID", "Title", reviews.MovieID);
            return(View(reviews));
        }
コード例 #30
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price,ImageURL,TrailerURL,Description")] Movie movie)
        {
            ViewBag.totalItems = HttpContext.Session.GetInt32("totalItems") != null?HttpContext.Session.GetInt32("totalItems") : 0;

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

                return(RedirectToAction(nameof(AdminIndex)));
            }
            return(View(movie));
        }