Пример #1
0
        public IActionResult UpdatePost(CourseAdd courseAdd)
        {
            Course course = new Course();

            course.Name = courseAdd.Name;
            course.ID   = courseAdd.CourseID;
            course.ESPB = courseAdd.ESPB;
            JArray typesArray = JArray.Parse(courseAdd.JsonString);

            course.ActivityTypes = typesArray.ToObject <List <ActivityType> >();
            foreach (ActivityType type in course.ActivityTypes)
            {
                type.CourseID = course.ID;
                type.Course   = course;
            }
            _courseData.Update(course);
            return(RedirectToAction("Courses", "Course"));
        }
Пример #2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Course.Id > 0)
            {
                _courseData.Update(Course);
                TempData["Message"] = "Course updated";
            }
            else
            {
                _courseData.Add(Course);
                TempData["Message"] = "Course created";
            }
            _courseData.Commit();

            return(RedirectToPage("./Details", new { courseId = Course.Id }));
        }