// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Teacher).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeacherExists(Teacher.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Kabinets.Add(Kabinet);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string[] selectedSubjects)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            UpdateClassSubjects(_context, selectedSubjects, SchoolClass);
            _context.SchoolClasses.Add(SchoolClass);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string[] selectedOptSubjects)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Student.StudentOptSubjectEnrollments = new List <StudentOptSubjectEnrollment>();
            _context.Students.Add(Student);
            _context.SaveChanges();
            UpdateStudentOptSubjects(_context, selectedOptSubjects, _context.Students.SingleOrDefault(c => c.IDCode == Student.IDCode));
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Kabinet = await _context.Kabinets.FindAsync(id);

            if (Kabinet != null)
            {
                _context.Kabinets.Remove(Kabinet);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Teacher = await _context.Teachers.FindAsync(id);

            if (Teacher != null)
            {
                _context.Teachers.Remove(Teacher);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SchoolClass = await _context.SchoolClasses.FindAsync(id);

            if (SchoolClass != null)
            {
                _context.SchoolClasses.Remove(SchoolClass);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int id, string[] selectedOptSubjects)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var studentToUpdate = await _context.Students
                                  .Include(c => c.StudentOptSubjectEnrollments).ThenInclude(c => c.OptSubject)
                                  .Include(c => c.StudentSchoolClassEnrollment).ThenInclude(c => c.SchoolClass)
                                  .FirstOrDefaultAsync(m => m.Id == id);

            if (studentToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Student>(
                    studentToUpdate,
                    "Student",
                    i => i.FirstMidName, i => i.LastName,
                    i => i.IDCode, i => i.StudentOptSubjectEnrollments))
            {
                if (String.IsNullOrWhiteSpace(
                        studentToUpdate.StudentOptSubjectEnrollments.ToString()))
                {
                    studentToUpdate.StudentOptSubjectEnrollments = null;
                }
                UpdateStudentOptSubjects(_context, selectedOptSubjects, studentToUpdate);
                UpdateStudentSchoolClass(_context, Student.StudentSchoolClassEnrollment.SchoolClassId, studentToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            UpdateStudentOptSubjects(_context, selectedOptSubjects, studentToUpdate);
            PopulateStudentOptSubjects(_context, studentToUpdate);
            PopulateClassesDropDownList(_context, studentToUpdate.StudentSchoolClassEnrollment.SchoolClassId);

            return(Page());
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int id, string[] selectedSubjects)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var schoolClassToUpdate = await _context.SchoolClasses
                                      .Include(c => c.SchoolClassSubjectAssignments).ThenInclude(c => c.Subject)
                                      .Include(c => c.SchoolClassKabinetAssignment).ThenInclude(c => c.Kabinet)
                                      .Include(c => c.TeacherSchoolClassAssignment).ThenInclude(c => c.Teacher)
                                      .FirstOrDefaultAsync(m => m.Id == SchoolClass.Id);

            if (await TryUpdateModelAsync <SchoolClass>(
                    schoolClassToUpdate,
                    "SchoolClass",
                    i => i.Name, i => i.SchoolClassSubjectAssignments,
                    i => i.StudentSchoolClassEnrollments,
                    i => i.TeacherSchoolClassAssignment))
            {
                if (String.IsNullOrWhiteSpace(
                        schoolClassToUpdate.SchoolClassSubjectAssignments.ToString()))
                {
                    schoolClassToUpdate.SchoolClassSubjectAssignments = null;
                }

                UpdateClassSubjects(_context, selectedSubjects, schoolClassToUpdate);
                UpdateKabinets(_context, SchoolClass.SchoolClassKabinetAssignment.KabinetId, schoolClassToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateKabinetsDropDownList(_context, SchoolClass);
            PopulateClassSubjects(_context, schoolClassToUpdate);
            return(RedirectToPage("./Index"));
        }