public async Task <TeacherAccount> RegisterNewTeachersAsync(TeacherAccountDTO newTeacherAccount) { TeacherAccount teacher = new TeacherAccount { Id = System.Guid.NewGuid(), TeacherAccountName = newTeacherAccount.TeacherAccountName, Password = newTeacherAccount.ConfirmPassword, TeacherFullName = newTeacherAccount.TeacherFullName }; await teachersAccountRepository.Create(teacher); return(teacher); }
public async Task <IActionResult> CreateNewUserAccountAsync([FromBody] TeacherAccountDTO newTeacherAccount) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TeacherAccount teacher = await teacherAccountService.RegisterNewTeachersAsync(newTeacherAccount); var uri = new Uri($"{Request.GetDisplayUrl()}/{teacher.Id}"); return(Created(uri, teacher)); } catch (Exception ex) { return(StatusCode(500, ex)); } }