public StudentSubjectScoreDTO AddStudentSubjectScore(StudentSubjectScoreDTO value, string token) { var studentEnrollmentExist = _masterService.GetOne <StudentEnrollment>(x => x.EnrollmentGUID == value.EnrollmentGUID && x.StudentGUID == value.StudentGUID); if (studentEnrollmentExist != null) { var repo = _unitOfWork.GetRepository <StudentSubjectScore>(); var newvalue = Mapper.Map <StudentSubjectScore>(value); newvalue.StudentEnrollmentGUID = studentEnrollmentExist.StudentEnrollmentGUID; //newvalue.CreatedBy = _appUserService.GetUserId(token); repo.Add(newvalue); repo.SaveChanges(); return(Mapper.Map <StudentSubjectScoreDTO>(newvalue)); } throw new Exception("Student is not in this enrollment"); }
public IActionResult AddStudentSubjectTest([FromBody] StudentSubjectScoreDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { //var idToken = HttpContext.GetTokenAsync(JwtBearerDefaults.AuthenticationScheme, "access_token"); //var token = idToken.Result; var studentSubjectScore = _studentService.AddStudentSubjectScore(value, ""); if (studentSubjectScore != null) { return(Ok(studentSubjectScore)); } return(BadRequest(new { message = "Cannot Add Student Subject Score" })); } catch (Exception e) { return(BadRequest(e)); } }