Ejemplo n.º 1
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.Student.Add(Student);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/Courses/EntryPage"));
        }
        // 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());
            }

            Rating.CourseID  = Course.ID;
            Rating.StudentID = (int)HttpContext.Session.GetInt32("ID");
            Rating.Date      = DateTime.Now;
            _context.Rating.Add(Rating);
            await _context.SaveChangesAsync();

            return(RedirectToPage("../Courses/Details", new { id = Course.ID }));
        }