Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Exemple #2
0
        public IActionResult Create(GradesModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _context.Add(model);
            _context.SaveChanges();

            return(View("Details", model));
        }
        public IActionResult Create(Student model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //Save the Data
            _context.Add(model);    //Adding the data to the context
            _context.SaveChanges(); //Saving the data to the table
            return(View("Details", model));
        }
        public IActionResult Create(StudentViewModel viewModel)
        {
            Student model = new Student();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //Populating our model
            model.Enrolled        = viewModel.student.Enrolled;
            model.StudentName     = viewModel.student.StudentName;
            model.StudentGenderId = viewModel.student.StudentGenderId;


            //Save the data
            _context.Add(model);    //Adding the data to the context
            _context.SaveChanges(); //Saving the data to the table

            return(View("Details", model));
        }