// GET: Course/Edit/5
        public ActionResult Edit(int id)
        {
            Student.Models.Course _Course = new Student.Models.Course();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                var CourseData = from CourseTable in EFDbContext.Courses
                                 where CourseTable.CourseID == id
                                 select CourseTable;
                if (CourseData.Any())
                {
                    _Course.CourseID = CourseData.First().CourseID;
                    _Course.Co_name  = CourseData.First().Co_name;

                    return(View(_Course));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            return(View(_Course));
        }
        public ActionResult Create(FormCollection collection)
        {
            Student.Models.Course _Course = new Student.Models.Course();
            try
            {
                // TODO: Add insert logic here
                using (TritonEntities EFDbContext = new TritonEntities())
                {
                    Student.Models.Course _info = new Student.Models.Course();
                    TryUpdateModel <Student.Models.Course>(_info, collection);
                    // Student _student = new Student();
                    //_Course.StudentID = _info.StudentID;
                    _Course.Co_name = _info.Co_name;
                    //_parent.Pa_sex = _info.Pa_sex;

                    EFDbContext.Courses.Add(_Course);
                    EFDbContext.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: Course/Delete/5
        public ActionResult Delete(int id)
        {
            Student.Models.Course _Course = new Student.Models.Course();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                var CourseData = from CourseTable in EFDbContext.Courses
                                 where CourseTable.CourseID == id
                                 select CourseTable;
                if (CourseData.Any())
                {
                    //_student = studentData.First();
                    //EFDbContext.Students.Remove(_student);
                    //EFDbContext.SaveChanges();

                    return(View(CourseData));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            return(View());
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            Student.Models.Course _Course = new Student.Models.Course();

            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                if (ModelState.IsValid)
                {
                    using (TritonEntities EFDbContext = new TritonEntities())
                    {
                        Student.Models.Course _info = new Student.Models.Course();
                        TryUpdateModel <Student.Models.Course>(_info, collection);
                        //var studentData = from studenTable in EFDbContext.Students
                        //                  where studenTable.StudentID == id
                        //                  select studenTable;
                        //if (studentData.Any())
                        //{
                        _Course.CourseID = _info.CourseID;
                        //_parent.ParentID = _info.St_address;
                        _Course.Co_name = _info.Co_name;

                        EFDbContext.SaveChanges();
                        return(RedirectToAction("Index"));
                        //}
                        //else
                        //{
                        //    return HttpNotFound();
                        //}
                    }
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            Student.Models.Course _Course = new Student.Models.Course();
            try
            {
                // TODO: Add delete logic here
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                using (TritonEntities EFDbContext = new TritonEntities())
                {
                    Student.Models.Course _info = new Student.Models.Course();
                    TryUpdateModel <Student.Models.Course>(_info, collection);

                    //var studentData = from studenTable in EFDbContext.Students
                    //                  where studenTable.StudentID == id
                    //                  select studenTable;
                    //if (studentData.Any())
                    //{
                    _Course = _info;
                    EFDbContext.Courses.Remove(_Course);
                    EFDbContext.SaveChanges();

                    return(RedirectToAction("Index"));
                    //}
                    //else
                    //{
                    //    return HttpNotFound();
                    //}
                }
            }
            catch
            {
                return(View());
            }
        }