public IActionResult AddCourse(AddCourseVM addCourseVM) { Guid teacherId = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); _teacherService.AddCourse(teacherId, addCourseVM.Title); return(RedirectToAction(nameof(Dashboard))); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } var result = _db.AddCourse(Course); if (result) { TempData["SM"] = $"Course {Course.CourseName} has been successfully edited"; } else { TempData["FM"] = $"Course {Course.CourseName} editing failed"; } if (result) { return(RedirectToPage("AllCourses")); } else { ModelState.AddModelError(string.Empty, "Course not created"); return(Page()); } }
public async Task <bool> AddCourse(int courseId, int teacherId) { return(await service.AddCourse(courseId, teacherId)); }