Exemplo n.º 1
0
        public void TestRegister()
        {
            var user = new UserViewModel()
            {
                FirstName = "Test",
                LastName  = "Test",
                Email     = "*****@*****.**",
                Password  = Md5Helper.Hash("6178")
            };

            var createdUser = UserCore.Create(user);

            Assert.AreEqual(true, createdUser.Success);

            var createdUserDb = UserCore.GetSingle(_user => _user.Email == user.Email);

            Assert.AreEqual(true, createdUser != null);
            Assert.AreEqual(user.FirstName, createdUserDb.FirstName, "FirstName");
            Assert.AreEqual(user.LastName, createdUserDb.LastName, "LastName");
            Assert.AreEqual(user.Password, createdUserDb.Password, "Passwords");

            var deleteUserResponse = UserCore.Delete(createdUserDb);

            Assert.AreEqual(true, deleteUserResponse);
        }
Exemplo n.º 2
0
 public IActionResult Post([FromBody][Required] User user)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     user = core.Create(user);
     return(CreatedAtRoute("GetUser", new { id = user.Id }, user));
 }
Exemplo n.º 3
0
        public JsonResult CreateUser(UserViewModel user)
        {
            if (user != null)
            {
                user.Password = Md5Helper.Hash(user.Password);
            }
            var createdUser = UserCore.Create(user);

            return(Json(createdUser));
        }
Exemplo n.º 4
0
        public UserCore SetupUser(int userId, int points)
        {
            User user = new User();

            user.Id        = userId;
            user.Points    = points;
            user.Email     = "*****@*****.**";
            user.FirstName = "Dana";
            user.LastName  = "Peele";
            core.Create(user);
            return(core);
        }