private void editcourse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                corseadd selectedcrs = coursess.SelectedItem as corseadd;
                selectedcrs.Name           = coursename.Text.ToString();
                selectedcrs.MaxDegree      = short.Parse(degreee.Text.ToString());
                selectedcrs.instructorName = instructorcourse.SelectedItem.ToString();

                instructor newins = context3.instructors.Where(em => em.FirstName == selectedcrs.instructorName).FirstOrDefault();

                course updatecourse =
                    (from cr in context3.courses
                     where cr.Name == selectedcrs.Name && cr.MaxDegree == selectedcrs.MaxDegree
                     select cr).FirstOrDefault();
                updatecourse.Name        = coursename.Text.ToString();
                updatecourse.MaxDegree   = short.Parse(degreee.Text.ToString());
                updatecourse.MinDegree   = 50;
                updatecourse.Description = updatecourse.Name + " is important";

                context3.SaveChanges();

                rel_instructor_cource updatecourseandinstructor = context3.rel_instructor_cource.Where(em => em.CourseId == updatecourse.CourseId).FirstOrDefault();
                updatecourseandinstructor.InsId = newins.InsId;
                context3.SaveChanges();
            }
            catch (Exception k)
            {
            }
        }
        private void coursess_Loaded(object sender, RoutedEventArgs e)
        {
            List <corseadd> newcourse = new List <corseadd>();

            var query =
                (from q in context3.courses
                 select q).ToList();
            var query2 =
                (from c in context3.instructors
                 select new { c.FirstName, c.InsId }
                ).ToList();

            foreach (var item in query)
            {
                corseadd addinstance = new corseadd();
                addinstance.CourseId    = item.CourseId;
                addinstance.Name        = item.Name;
                addinstance.Description = item.Description;
                addinstance.MaxDegree   = item.MaxDegree;
                addinstance.MinDegree   = item.MinDegree;

                rel_instructor_cource instructorId = context3.rel_instructor_cource.Where(em => em.CourseId == item.CourseId).FirstOrDefault();
                foreach (var item2 in query2)
                {
                    if (instructorId.InsId == item2.InsId)
                    {
                        addinstance.instructorName = item2.FirstName;
                    }
                }
                newcourse.Add(addinstance);
                coursess.Items.Add(addinstance);
            }
        }
        private void addcourse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                corseadd newcourse = new corseadd();

                newcourse.Name = coursename.Text.ToString();

                newcourse.MaxDegree = 100;

                newcourse.instructorName = instructorcourse.SelectedItem.ToString();

                instructor newins = context3.instructors.Where(em => em.FirstName == newcourse.instructorName).FirstOrDefault();

                rel_instructor_cource newcourseinstructor = new rel_instructor_cource();


                course newCourseAdd = new course();
                newCourseAdd.Name        = coursename.Text.ToString();
                newCourseAdd.MinDegree   = 50;
                newCourseAdd.MaxDegree   = 100;
                newCourseAdd.Description = coursename.Text.ToString() + "is important";
                context3.courses.Add(newCourseAdd);
                context3.SaveChanges();
                newcourseinstructor.CourseId = newCourseAdd.CourseId;
                newcourseinstructor.InsId    = newins.InsId;
                newcourseinstructor.Year     = DateTime.Now;

                context3.rel_instructor_cource.Add(newcourseinstructor);
                context3.SaveChanges();
                coursess.Items.Add(newcourse);
            }
            catch (Exception f)
            {
                MessageBox.Show("Invalid Inputs");
            }
        }