public IHttpActionResult PutStudent(int id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.Id)
            {
                return(BadRequest());
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Create([Bind(Include = "StudentId,FristName,LastName,Grade")] StudentList studentList)
 {
     if (ModelState.IsValid)
     {
         entities.StudentList.Add(studentList);
         entities.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(studentList));
 }
 public ActionResult Create(StudentsTable st)
 {
     if (st != null)
     {
         db.StudentsTable.Add(st);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(st));
 }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "StudentID,FirstName,LastName,ParentsNames,Address,City,StateOrProvince,PostalCode,PhoneNumber,EmailName,Major,StudentNumber,Notes")] Students students)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(students);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(students));
        }
        public ActionResult Create([Bind(Include = "id,Batch1,Year")] Batch batch)
        {
            if (ModelState.IsValid)
            {
                db.Batches.Add(batch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(batch));
        }
        public ActionResult Signin([Bind(Include = "Aid,Apassword,Aname")] Administrator administrator)
        {
            if (ModelState.IsValid)
            {
                db.Administrator.Add(administrator);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            return(View(administrator));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "id,FirstName,LastName,Username,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "ClassID,ClassName,DepartmentID,Section__,InstructorID,Term,Units,Year,Location,DaysAndTimes,Notes")] Classes classes)
        {
            if (ModelState.IsValid)
            {
                db.Classes.Add(classes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(classes));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "id,Course1,Duration")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
        public ActionResult Create([Bind(Include = "Sno,Spassword,Sname,Ssex,Sage,Sdepartment,Smajor,Sclass,Sgpa,Scampus")] StudentInfor studentInfor)
        {
            if (ModelState.IsValid)
            {
                db.StudentInfor.Add(studentInfor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(studentInfor));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "PersonID,LastName,FirstName,HireDate,EnrollmentDate,Discriminator")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PersonID = new SelectList(db.OfficeAssignments, "InstructorID", "Location", person.PersonID);
            return(View(person));
        }
Exemplo n.º 12
0
        public ActionResult Delete(FormCollection fcNotUsed, int id = 0)
        {
            Student student = std.Students.Find(id);

            if (student == null)
            {
                return(HttpNotFound());
            }
            std.Students.Remove(student);
            std.SaveChanges();
            return(RedirectToAction("Home"));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "id,FirstName,LastName,NIC,Course_id,Batch_id,Cell_no")] Registration registration)
        {
            if (ModelState.IsValid)
            {
                db.Registrations.Add(registration);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Batch_id  = new SelectList(db.Batches, "id", "Batch1", registration.Batch_id);
            ViewBag.Course_id = new SelectList(db.Courses, "id", "Course1", registration.Course_id);
            return(View(registration));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "CourseID,Title,Credits,DepartmentID")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", course.DepartmentID);
            ViewBag.CourseID     = new SelectList(db.OnlineCourses, "CourseID", "URL", course.CourseID);
            ViewBag.CourseID     = new SelectList(db.OnsiteCourses, "CourseID", "Location", course.CourseID);
            return(View(course));
        }
Exemplo n.º 15
0
 //PostCourse for example is better not to have http post
 public CourseDto CreateCourse(CourseDto courseDto)
 {
     //Validate the model first
     if (!ModelState.IsValid)
     {
         throw new HttpResponseException(HttpStatusCode.BadRequest);
     }
     else
     {
         var course = Mapper.Map <CourseDto, Course>(courseDto);
         _DbContext.Courses.Add(course);
         _DbContext.SaveChanges();
         courseDto.CourseID = course.CourseID;
         return(courseDto);
     }
 }
Exemplo n.º 16
0
        public ActionResult Create_Post()
        {
            var menusmodel = new Student();

            TryUpdateModel(menusmodel);

            using (var r = new StudentsEntities())
            {
                r.Students.Add(menusmodel);
                r.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 17
0
        public ActionResult Register(Credential c)
        {
            if (ModelState.IsValid)
            {
                s.Credentials.Add(c);
                s.SaveChanges();

                return(RedirectToAction("Login"));
            }
            else
            {
                return(View("Register"));
            }
        }
Exemplo n.º 18
0
        public JsonResult SaveDataInDatabase(StudentViewModel model)
        {
            var result = false;

            try
            {
                if (model.StudentId > 0)
                {
                    Student Stu = db.Students.SingleOrDefault(x => x.IsDeleted == false && x.StudentId == model.StudentId);
                    Stu.Name        = model.Name;
                    Stu.Address     = model.Address;
                    Stu.PhoneNumber = model.PhoneNumber;
                    Stu.DegreeID    = model.DegreeID;
                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Student Stu = new Student();
                    Stu.Name        = model.Name;
                    Stu.Address     = model.Address;
                    Stu.PhoneNumber = model.PhoneNumber;
                    Stu.DegreeID    = model.DegreeID;
                    Stu.IsDeleted   = false;
                    db.Students.Add(Stu);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        public ActionResult Edit_Post(int Id)
        {
            var menumodel = new Student();

            TryUpdateModel(menumodel);

            using (var r = new StudentsEntities())
            {
                var m = r.Students.Where(x => x.Id == Id).FirstOrDefault();
                TryUpdateModel(m);
                r.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }