/// <summary>
        /// Same method ("/user/index/"), but this one is only called
        /// from POST requests.
        /// </summary>
        /// <returns></returns>
        public IActionResult IndexPost()
        {
            // This is how easy a user is filled with info from a form:
            User user = new User();

            PropertyAssigner.Assign(user, Parameters);

            // Save object in your database.

            return(Redirect("/user/index/"));
        }
Exemple #2
0
        public void Test()
        {
            var user = new User();

            ParameterCollection col = new ParameterCollection {
                { "Name", "Jonas" }, { "Age", "17" }
            };

            PropertyAssigner.Assign(user, col);
            Assert.Equal("Jonas", user.Name);
            Assert.Equal(17, user.Age);
        }