public IHttpActionResult Post([FromBody] User user) { if (user == null) { return(BadRequest("User can't be empty")); } if (userModel.UserExist(user.UserName)) { return(BadRequest("The user already exist")); } var objectUser = AutoMapper.Mapper.Map <Objects.User>(user); if (userModel.CreateUser(objectUser)) { user.Password = null; return(CreatedAtRoute("DefaultApi", new { id = user.UserName }, user)); } else { return(InternalServerError()); } }