Пример #1
0
        /// <summary>
        /// IAction method for adding a question to a course
        /// </summary>
        /// <param name="courseid">Id for a question answer</param>
        /// <param name="questionAnswerid">Id for a course</param>
        /// <returns></returns>
        public IActionResult AddQuestionAnswer(int questionAnswerId, int courseId)
        {
            try
            {
                if (!ModelState.IsValid || questionAnswerId == 0)
                {
                    return(RedirectToAction("Details", new { id = courseId }));
                }

                var qa     = context.ReadQuesAnswer(questionAnswerId);
                var course = context.ReadCourse(courseId);
                context.AddQAToACourse(qa, course);
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }

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