예제 #1
0
 public IActionResult Post([FromBody] User user)
 {
     if (UserDataAccess.Add(user))
     {
         return(Created($"/api/Users/{user.Email}", user));
     }
     else
     {
         return(new BadRequestResult());
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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()));
        }
예제 #4
0
        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"));
        }
예제 #5
0
        public IHttpActionResult Add(User newUser)
        {
            var user = userRepository.Add(newUser);

            return(Ok(user));
        }
예제 #6
0
 public void Add(User user)
 {
     //Validation and logic
     _userDataAccess.Add(user);
 }