Пример #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(Course).State = EntityState.Modified;

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

            return(RedirectToPage("./Index"));
        }
Пример #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.Courses.Add(Course);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #3
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.Students.Add(Student);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Students"));
        }
Пример #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)
            {
                // need to recreate the Course object AND the list of instructors before
                // showing the page if we have errors
                Course = _context.Courses.FirstOrDefault(c => c.CourseId == Section.CourseId);
                ViewData["InstructorId"] = GetSelectListItems();
                return(Page());
            }

            _context.Sections.Add(Section);
            await _context.SaveChangesAsync();

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

            Section = await _context.Sections.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (Course == null || Course.CourseId == 0)
            {
                return(NotFound());
            }

            //Course = await _context.Courses.FindAsync(Course.CourseId);

            _context.Remove(Course);
            await _context.SaveChangesAsync();

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

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