public IActionResult Post([FromBody] User user) { if (UserDataAccess.Add(user)) { return(Created($"/api/Users/{user.Email}", user)); } else { return(new BadRequestResult()); } }
public void LoginIntegrationTest_validParameters_Ok() { IUserDataAccess da = new UserDataAccess(); ILoginBusinessLogic login = new LoginBusinessLogic(da); Guid guid = user.Token; da.Add(user); login.Login(user.Username, user.Password); Guid tokenObtained = da.Get(user.Username).Token; Assert.AreNotEqual(guid, tokenObtained); }
public void AuthIntegtrationTest_ExpectedValues_Ok() { IUserDataAccess da = new UserDataAccess(); IAuthorizationBusinessLogic auth = new AuthorizationBusinessLogic(da); user.IsAdmin = true; da.Add(user); Assert.IsTrue(auth.IsAdmin(user.Token)); Assert.IsTrue(auth.IsAValidToken(user.Token)); Assert.IsFalse(auth.IsAValidToken(Guid.NewGuid())); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } User VerifiedUser = userDataAccess.GetByUserName(RegisteredUser.UserName); if (VerifiedUser != null) { TempData["Message"] = $"Username:{RegisteredUser.UserName} is taken"; return(RedirectToPage("./UserPage")); } RegisteredUser = userDataAccess.Add(RegisteredUser); userDataAccess.Commit(); return(RedirectToPage("./UserPage")); }
public IHttpActionResult Add(User newUser) { var user = userRepository.Add(newUser); return(Ok(user)); }
public void Add(User user) { //Validation and logic _userDataAccess.Add(user); }