public ActionResult Register(RegisterViewModel registermodel)
 {
     if (!ModelState.IsValid) //Checks if input fields have the correct format
     {
         return View(registermodel); //Returns the view with the input values so that the user doesn't have to retype again
     }
     if (CheckIfuserExist(registermodel))
     {
         ViewBag.AlertMessage = "This username or email address already exist!";
         return View(registermodel);
     }
     User user = new User()
        {
            Id = Guid.NewGuid(),
            Email = registermodel.Email,
            Username = registermodel.Username,
            FirstName = registermodel.FirstName,
            LastName = registermodel.LastName,
            Password = registermodel.Password
        };
     Role role = _roleService.GetAll().Find(r => r.RoleName == "OwnSurveuAdmin");
     role.Users.Add(user);
     _userService.AddUser(user);
     _userService.SaveChanges();
     return RedirectToAction("Login", "Authentication");
 }
 public void AddUser(User role)
 {
     _userRepository.Add(role);
 }