示例#1
0
        /// <summary>
        /// IAction method for displaying the view of a delete function
        /// </summary>
        /// <param name="id">Id for a Student</param>
        /// <returns></returns>
        public IActionResult Delete(int id)
        {
            var student = context.ReadStudent(id);

            if (student == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(student));
        }
示例#2
0
        /// <summary>
        /// IAction method for returning a student addition to a course
        /// </summary>
        /// <param name="studentId">Id for a student</param>
        /// <param name="courseId">Id for a course</param>
        /// <returns></returns>
        public IActionResult AddStudent(int studentId, int courseId)
        {
            try
            {
                if (!ModelState.IsValid || studentId == 0)
                {
                    return(RedirectToAction("Details", new { id = courseId }));
                }

                var student = context.ReadStudent(studentId);
                var course  = context.ReadCourse(courseId);
                context.AddStudentToACourse(student, course);
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }

            return(RedirectToAction("Details", new { id = courseId }));
        }