Пример #1
0
        public ActionResult Create(FormCollection collection)
        {
            Student.Models.Student _student = new Student.Models.Student();
            try
            {
                // TODO: Add insert logic here
                using (TritonEntities EFDbContext = new TritonEntities())
                {
                    Student.Models.Student _info = new Student.Models.Student();
                    TryUpdateModel <Student.Models.Student>(_info, collection);
                    // Student _student = new Student();
                    //_student.StudentID = _info.StudentID;
                    _student.St_address  = _info.St_address;
                    _student.St_birthday = _info.St_birthday;
                    _student.St_name     = _info.St_name;
                    _student.St_la       = _info.St_la;
                    _student.St_long     = _info.St_long;
                    EFDbContext.Students.Add(_student);
                    EFDbContext.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        public ActionResult Create(FormCollection collection)
        {
            Student.Models.Benchmark _Benchmark = new Student.Models.Benchmark();
            try
            {
                // TODO: Add insert logic here
                using (TritonEntities EFDbContext = new TritonEntities())
                {
                    Student.Models.Benchmark _info = new Student.Models.Benchmark();
                    TryUpdateModel <Student.Models.Benchmark>(_info, collection);
                    // Student _student = new Student();
                    _Benchmark.StudentID      = _info.StudentID;
                    _Benchmark.CourseID       = _info.CourseID;
                    _Benchmark.benchmarkRange = _info.benchmarkRange;

                    EFDbContext.Benchmarks.Add(_Benchmark);
                    EFDbContext.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
        public ActionResult Edit(int?id, FormCollection collection)
        {
            Student.Models.Student _student = new Student.Models.Student();

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

                if (ModelState.IsValid)
                {
                    using (TritonEntities EFDbContext = new TritonEntities())
                    {
                        Student.Models.Student _info = new Student.Models.Student();
                        TryUpdateModel <Student.Models.Student>(_info, collection);
                        //var studentData = from studenTable in EFDbContext.Students
                        //                  where studenTable.StudentID == id
                        //                  select studenTable;
                        //if (studentData.Any())
                        //{
                        //_student.StudentID = _info.StudentID;
                        _student.St_address  = _info.St_address;
                        _student.St_birthday = _info.St_birthday;
                        _student.St_name     = _info.St_name;
                        EFDbContext.SaveChanges();
                        return(RedirectToAction("Index"));
                        //}
                        //else
                        //{
                        //    return HttpNotFound();
                        //}
                    }
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #5
0
        public ActionResult Delete(int?id, FormCollection collection)
        {
            Student.Models.Student _student = new Student.Models.Student();
            try
            {
                // TODO: Add delete logic here
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                using (TritonEntities EFDbContext = new TritonEntities())
                {
                    Student.Models.Student _info = new Student.Models.Student();
                    TryUpdateModel <Student.Models.Student>(_info, collection);

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

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