Exemple #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());
            }
        }
        // GET: Google/Details/5
        public ActionResult Details(int id)
        {
            Student.Models.Student _student = new Student.Models.Student();
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }


                var studentData = from studenTable in EFDbContext.Students
                                  where studenTable.StudentID == id
                                  select studenTable;
                if (studentData.Any())
                {
                    ViewBag.la = studentData.First().St_la;
                    ViewBag.lo = studentData.First().St_long;
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            return(View());
        }
Exemple #3
0
        // GET: Student/Details/5
        public ActionResult Details(int?id)
        {
            Student.Models.Student _student = new Student.Models.Student();
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }


                var studentData = from studenTable in EFDbContext.Students
                                  where studenTable.StudentID == id
                                  select studenTable;
                if (studentData.Any())
                {
                    _student.StudentID   = studentData.First().StudentID;
                    _student.St_address  = studentData.First().St_address;
                    _student.St_birthday = studentData.First().St_birthday;
                    _student.St_name     = studentData.First().St_name;
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            return(View(_student));
        }
Exemple #4
0
        // GET: Student/Delete/5
        public ActionResult Delete(int id)
        {
            Student.Models.Student _student = new Student.Models.Student();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                var studentData = from studenTable in EFDbContext.Students
                                  where studenTable.StudentID == id
                                  select studenTable;
                if (studentData.Any())
                {
                    //_student = studentData.First();
                    //EFDbContext.Students.Remove(_student);
                    //EFDbContext.SaveChanges();

                    return(View(_student));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            return(View());
        }
 public ActionResult DeleteConfirmed(int id)
 {
     Student.Models.Student student = db.Students.Find(id);
     db.Students.Remove(student);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit([Bind(Include = "Id,Firstname,Lastname,DateOfBirth,GPA")] Student.Models.Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
        public ActionResult Create([Bind(Include = "Id,Firstname,Lastname,DateOfBirth,GPA")] Student.Models.Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
 // GET: Students/Delete/5
 public ActionResult Delete(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Student.Models.Student student = db.Students.Find(id);
     if (student == null)
     {
         return(HttpNotFound());
     }
     return(View(student));
 }
Exemple #9
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());
            }
        }
Exemple #10
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());
            }
        }