コード例 #1
0
        public ViewResult Detail(int id)
        {
            var             model   = new HomePageViewModel();
            SQLEmployeeData sqlData = new SQLEmployeeData(_context);

            Employee employee = sqlData.Get(id);

            return(View(employee));
        }
コード例 #2
0
        public ViewResult Detail(int id)
        {
            var model = new HomePageViewModel();
            //var employee = new Employee() { ID = 1, Name = "张三" };
            //return View(employee);

            SQLEmployeeData sqlData  = new SQLEmployeeData(_context);
            Employee        employee = sqlData.Get(id);

            return(View(employee));
        }
コード例 #3
0
        public IActionResult Edit(int id, EmployeeEditViewModel input)
        {
            SQLEmployeeData sqlData  = new SQLEmployeeData(_context);
            var             employee = sqlData.Get(id);

            if (null != employee && ModelState.IsValid)
            {
                employee.Name = input.Name;
                _context.SaveChanges();
                return(RedirectToAction("Detail", new { id = employee.ID }));
            }
            return(View(employee));
        }
コード例 #4
0
        public IActionResult Edit(int id)
        {
            var             model    = new HomePageViewModel();
            SQLEmployeeData sqlData  = new SQLEmployeeData(_context);
            Employee        employee = sqlData.Get(id);

            if (null == employee)
            {
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }