public bool CreateUser(ApplicationUserDTO user) { if (user is null) { throw new AccountException("User is null"); } var us = new ApplicationUser() { Email = user.Email, Surname = user.Surname, UserName = user.Name }; var role = user.Roles; var create = userManager.CreateAsync(us, user.Password).Result; var roles = userManager.AddToRolesAsync(us, role).Result; if (create.Succeeded && roles.Succeeded) { database.Users.Create(mapper.Map <User>(new UserDTO() { IdenityId = userManager.GetUserIdAsync(us).Result })); string path = userManager.GetUserIdAsync(us).Result; FileManagment.CreateFolder(path); database.Save(); return(true); } else { throw new AccountException("User or Role wasn't created"); } }