public async Task <ActionResult> CreateStudent([FromBody] StudentRegisterDTO newStudent) { newStudent.Password = AuthentificationService.EncryptPassword(newStudent.Password); string base64Image = newStudent.Student.ProfilePicturePath; if (!string.IsNullOrEmpty(base64Image)) { string imageFileId = await _sharedRepository.GetNextImageId(); newStudent.Student.ProfilePicturePath = FileManagerService.SaveImageToFile(base64Image, imageFileId); } if (await _repository.CreateNonExistingStudent(newStudent)) { StudentDTO student = await _repository.StudentExists(newStudent.Student.Email); student.Student.ProfilePicturePath = base64Image; string token = JwtManager.GenerateJWToken(student.Student, student.Id.ToString()); return(Ok(new JsonResult(token))); } else { return(Ok(new JsonResult("Email taken"))); } }