コード例 #1
0
        public IActionResult Index()
        {
            var model = new Models.Home.EmployeeViewModel
            {
                Id = 5
            };

            return(View(model));
        }
コード例 #2
0
        public IActionResult Index(Models.Home.EmployeeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var json = JsonConvert.SerializeObject(model);

            return(Content(json));
        }
コード例 #3
0
        public IActionResult Index()
        {
            var model = new Models.Home.EmployeeViewModel
            {
                Id        = 1,
                Firstname = "Lei",
                Surname   = "Li",
                Address   = new Models.Home.AddressViewModel
                {
                    Line1 = "Shanghai",
                    Line2 = "PuDong",
                    Line3 = "BiBoRoad"
                }
            };

            return(View(model));
        }