public ActionResult Create(InstructorCreateEditViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                using (SqlConnection conn = Connection)
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = @"INSERT INTO Instructor 
                                            (FirstName, LastName, SlackHandle, Specialty, CohortId)
                                            VALUES
                                            (@firstName, @lastName, @slackHandle, @specialty, @cohortId)";
                        cmd.Parameters.AddWithValue("@firstName", model.Instructor.FirstName);
                        cmd.Parameters.AddWithValue("@lastName", model.Instructor.LastName);
                        cmd.Parameters.AddWithValue("@slackHandle", model.Instructor.SlackHandle);
                        cmd.Parameters.AddWithValue("@specialty", model.Instructor.Specialty);
                        cmd.Parameters.AddWithValue("@cohortId", model.Instructor.CohortId);
                        cmd.ExecuteNonQuery();
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult Edit(int id, InstructorCreateEditViewModel model)
 {
     try
     {
         // TODO: Add update logic here
         using (SqlConnection conn = Connection)
         {
             conn.Open();
             using (SqlCommand cmd = conn.CreateCommand())
             {
                 cmd.CommandText = @"UPDATE Instructor 
                                     SET
                                         FirstName = @firstName, 
                                         LastName = @lastName, 
                                         SlackHandle = @slackHandle, 
                                         Specialty = @specialty, 
                                         CohortId = @cohortId
                                     WHERE Id = @id";
                 cmd.Parameters.AddWithValue("@firstName", model.Instructor.FirstName);
                 cmd.Parameters.AddWithValue("@lastName", model.Instructor.LastName);
                 cmd.Parameters.AddWithValue("@slackHandle", model.Instructor.SlackHandle);
                 cmd.Parameters.AddWithValue("@specialty", model.Instructor.Specialty);
                 cmd.Parameters.AddWithValue("@cohortId", model.Instructor.CohortId);
                 cmd.Parameters.AddWithValue("@id", id);
                 cmd.ExecuteNonQuery();
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
        // GET: Instructors/Create
        public ActionResult Create()
        {
            var cohorts   = GetAllCohorts();
            var viewModel = new InstructorCreateEditViewModel(cohorts);

            return(View(viewModel));
        }
        // GET: Instructors/Edit/5
        public ActionResult Edit(int id)
        {
            Instructor instructor = GetSingleInstructor(id);
            var        cohorts    = GetAllCohorts();
            var        viewModel  = new InstructorCreateEditViewModel(instructor, cohorts);

            return(View(viewModel));
        }