示例#1
0
        // To protect from overposting attacks, 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(StudentCourse).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentCourseExists(StudentCourse.StudentID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("/Courses/Details", new { id = StudentCourse.CourseID }));
        }
示例#2
0
        // To protect from overposting attacks, 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(Course).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourseExists(Course.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }
            if (DateTime.Compare(Student.DateOfBirth, DateTime.Now) >= 0)
            {
                TempData["DateOfBirthMessage"] = "Data nasterii trebuie sa fie in trecut";
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(Student.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
示例#4
0
        // To protect from overposting attacks, 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.Course.Add(Course);
            await _context.SaveChangesAsync();

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

            Course = await _context.Course.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
示例#6
0
        public async Task <IActionResult> OnPostAsync(int?studentId, int?courseId)
        {
            if (studentId == null || courseId == null)
            {
                return(NotFound());
            }

            StudentCourse = await _context.StudentCourse.FindAsync(studentId, courseId);

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

            return(RedirectToPage("/Courses/Details", new { id = StudentCourse.CourseID }));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Student = await _context.Student.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }
            if (DateTime.Compare(Student.DateOfBirth, DateTime.Now) >= 0)
            {
                TempData["DateOfBirthMessage"] = "Data nasterii trebuie sa fie in trecut";
                return(Page());
            }

            _context.Student.Add(Student);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }

            var studentDejaInscris = _context.StudentCourse
                                     .FirstOrDefault(m => m.StudentID == StudentCourse.StudentID && m.CourseID == StudentCourse.CourseID);

            if (studentDejaInscris != null)
            {
                TempData["StudentDejaInscrisMessage"] = "Studentul este deja inscris la acest curs";
                return(OnGet());
            }

            _context.StudentCourse.Add(StudentCourse);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/Courses/Details", new { id = StudentCourse.CourseID }));
        }
        // To protect from overposting attacks, 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());
            }
            if (DateTime.Compare(Teacher.ContractStart, DateTime.Now) <= 0)
            {
                TempData["ContractStartAfterTodayMessage"] = "Inceputul contractului trebuie sa fie in viitor";
                return(Page());
            }
            if (Teacher.ContractEnd.HasValue && DateTime.Compare(Teacher.ContractStart, Teacher.ContractEnd.Value) >= 0)
            {
                TempData["ContractStartAfterContractEndMessage"] = "Finalul contractului trebuie sa fie dupa inceputul contractului";
                return(Page());
            }

            _context.Teacher.Add(Teacher);
            await _context.SaveChangesAsync();

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

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

            if (Teacher.TeachesCourses)
            {
                return(Page());
            }

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

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }
            if (DateTime.Compare(Teacher.ContractStart, DateTime.Now) <= 0)
            {
                TempData["ContractStartAfterTodayMessage"] = "Inceputul contractului trebuie sa fie in viitor";
                return(Page());
            }
            if (Teacher.ContractEnd.HasValue && DateTime.Compare(Teacher.ContractStart, Teacher.ContractEnd.Value) >= 0)
            {
                TempData["ContractStartAfterContractEndMessage"] = "Finalul contractului trebuie sa fie dupa inceputul contractului";
                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"));
        }