public IActionResult Create(CourseEditModel model) { var newCourse = new Course(); newCourse.Title = model.Title; newCourse.TecnologyCourse = model.Tecnology; newCourse.idAutor = _autorData.GetAutorByName(model.AutorName).id; newCourse = _courseData.Add(newCourse); return(View(nameof(Details), newCourse)); }
public IActionResult AddPost(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> >(); _courseData.Add(course); return(RedirectToAction("Courses", "Course")); }
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 })); }