Пример #1
0
        public IActionResult Index()
        {
            var viewModel = new StudentInstructorViewModel();

            viewModel.Students    = GetAllStudents();
            viewModel.Instructors = GetAllInstructors();
            return(View(viewModel));
        }
Пример #2
0
        public IActionResult Index()
        {
            //view model accepts a connection string so we need to pass it one
            var students    = GetAllStudents();
            var instructors = GetAllInstructors();
            var viewModel   = new StudentInstructorViewModel(students, instructors);

            return(View(viewModel));
        }
        public IActionResult Index()
        {
            var viewModel = new StudentInstructorViewModel();
            viewModel.Students = GetAllStudents();
            viewModel.Instructors = GetAllInstructors();

            // View method comes from the parent class "Controller"
            return View(viewModel);
        }
        public async Task <IActionResult> Index()
        {
            var         viewModel = new StudentInstructorViewModel();
            List <Task> tasks     = new List <Task>()
            {
                Task.Run(async() => viewModel.Students    = await GetAllStudents()),
                Task.Run(async() => viewModel.Instructors = await GetAllInstructors()),
            };
            await Task.WhenAll(tasks);

            return(View(viewModel));
        }
Пример #5
0
 public IActionResult Index()
 {
     using (SqlConnection conn = Connection)
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             StudentInstructorViewModel StudentInstructorViewModel = new StudentInstructorViewModel(_config.GetConnectionString("DefaultConnection"));
             return(View(StudentInstructorViewModel));
         }
     }
 }
        public IActionResult Index()
        {
            // go to the database
            // do some logic

            using (SqlConnection conn = Connection)
            {
                conn.Open();

                using (SqlCommand cmd = conn.CreateCommand())
                {
                    StudentInstructorViewModel studentInstructorViewModel = new StudentInstructorViewModel(_config.GetConnectionString("DefaultConnection"));
                    return(View(studentInstructorViewModel));
                }
            }
        }
Пример #7
0
        public IActionResult Index()
        {
            var viewModel = new StudentInstructorViewModel(_config.GetConnectionString("DefaultConnection"));

            return(View(viewModel));
        }
Пример #8
0
        public ActionResult Index()
        {
            StudentInstructorViewModel model = new StudentInstructorViewModel(_connectionstring);

            return(View(model));
        }