public async Task <ActionResult> CreateTeacher([FromBody] CreateTeacherViewModel model)
        {
            if (ModelState.IsValid)
            {
                // creating the school
                var school = new School(model.SchoolName, GetRandomString(6));
                _schoolRepository.Add(school);
                await _schoolRepository.SaveChanges();

                // creating teacher consisting of his school
                var user = _authenticationManager.CreateApplicationUserObject(model.Email, model.Username,
                                                                              model.Password);
                user.School = await _schoolRepository.GetByName(model.SchoolName);

                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    user = _userManager.Users.SingleOrDefault(u => u.Id == user.Id);
                    if (user.School == null)
                    {
                        return(Ok(
                                   new
                        {
                            Message = "Something went wrong when creating your account."
                        }));
                    }
                    await _userManager.AddToRoleAsync(user, "Teacher");


                    var claim = await CreateClaims(user);

                    //Todo kunnen van CreateClaims in List werken idpv array zodat men niet hoeft de array naar list om te zetten
                    // en in addschoolclaim hoeft men dan geen returnwaarde te geven (want het Adden vd claim is op reference van de lijst)
                    claim = _authenticationManager.AddClaim(claim.ToList(), "school", school.Id.ToString()).ToArray();

                    var token = GetToken(claim);

                    return(Ok(
                               new
                    {
//                            Username = user.UserName,
//                            Token = GetToken(claim)
                        token = new JwtSecurityTokenHandler().WriteToken(token),
                        expiration = token.ValidTo
                    }));
                }
            }

            return(Ok(
                       new
            {
                Message = "Error please make sure your details are correct"
            }));
        }