示例#1
0
        public ActionResult Edit(CreateStudent studentdata)
        {
            var std = repo.getByID(studentdata.Student.ID);

            if (std == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                repo.Edit(studentdata);
                return(RedirectToAction("Index"));
            }
            ViewBag.FieldId       = new SelectList(frepo.getAll(), "ID", "Name", studentdata.Student.FieldId);
            ViewBag.GovernorateId = new SelectList(grepo.getAll(), "ID", "Name", studentdata.Student.GovernorateId);
            return(View(studentdata));
        }
示例#2
0
 public ActionResult Create(CreateStudent sstd)
 {
     if (ModelState.IsValid)
     {
         repo.add(sstd.Student);
         foreach (var TeacherId in sstd.TeacherId)
         {
             strepo.AddTeacherToStudent(new StudentTeacher()
             {
                 StudentId = sstd.Student.ID, TeacherId = TeacherId
             });
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.FieldId         = new SelectList(frepo.getAll(), "ID", "Name", sstd.Student.FieldId);
     ViewBag.GovernorateId   = new SelectList(grepo.getAll(), "ID", "Name", sstd.Student.GovernorateId);
     ViewBag.NeighborhoodId  = new SelectList(nrepo.getAll(), "ID", "Name", sstd.Student.NeighborhoodId);
     ViewBag.selected        = new SelectList(nrepo.getAll(), "ID", "Name", sstd.Student.ID);
     ViewBag.StudentTeachers = new SelectList(trepo.getAll(), "ID", "Name");
     return(View(sstd));
 }
示例#3
0
        // GET: Student/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            Student student     = repo.getByID(id.Value);
            var     TeacherIds  = strepo.GetStudentTeachers(id.Value);
            var     StudentDate = new CreateStudent()
            {
                Student = student, TeacherId = TeacherIds
            };

            if (student == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FieldId         = new SelectList(frepo.getAll(), "ID", "Name", student.FieldId);
            ViewBag.GovernorateId   = new SelectList(grepo.getAll(), "ID", "Name", student.GovernorateId);
            ViewBag.NeighborhoodId  = new SelectList(nrepo.getAll(), "ID", "Name", student.NeighborhoodId);
            ViewBag.StudentTeachers = new SelectList(trepo.getAll(), "ID", "Name");
            return(View(StudentDate));
        }