public async Task <IActionResult> AddCourse(string teacherId, int courseId) { try { await _teacherRepo.AddCourse(courseId, teacherId); return(Ok(new ResponseModel("00", "Success", null))); } catch (Exception ex) { return(BadRequest(new ResponseModel("22", "Failed", new { ex.Message }))); } }
public async Task <IActionResult> AddCourse([FromBody] CourseForAddDto courseForAdd, int teacherId) { string auth = Request.Headers["Authorization"]; // get bearer string if (AuthHelper.BasicAuth(auth, teacherId, "Teacher") == false) { return(Unauthorized()); } var course = _mapper.Map <Course>(courseForAdd); var courseToReturn = _mapper.Map <CourseForDetailedDto>(await _repo.AddCourse(course, teacherId)); return(Ok(courseToReturn)); }
public ActionResult NewClassReq(string Title) { LoginDetails loginDetails = (LoginDetails)Session["loginDetails"]; if (loginDetails == null) { return(RedirectToAction("PageNotFoundError", "Home")); } int user = (int)Session["user"]; if (user != 1) { return(RedirectToAction("PageNotFoundError", "Home")); } data.AddCourse(loginDetails.Username, Title); return(RedirectToAction("Home")); }