Exemplo n.º 1
0
        public IActionResult OnPost(int courseId)
        {
            var course = _courseData.Delete(courseId);

            _courseData.Commit();

            if (course == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            TempData["Message"] = $"{course.Name} deleted";

            return(RedirectToPage("./List"));
        }
Exemplo n.º 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 }));
        }