Example #1
0
        public ViewResult Detail(int Id)
        {
            SQLEmployeeData sqlData  = new SQLEmployeeData(_netCoreDBContext);
            Employee        employee = sqlData.Get(Id);

            return(View(employee));
        }
Example #2
0
        public ViewResult Index()
        {
            var             model   = new HomePageViewModel();
            SQLEmployeeData sqlData = new SQLEmployeeData(_netCoreDBContext);

            model.Employees = sqlData.GetAll();
            return(View(model));
        }
Example #3
0
        public IActionResult Edit(int Id)
        {
            SQLEmployeeData sqlData  = new SQLEmployeeData(_netCoreDBContext);
            Employee        employee = sqlData.Get(Id);

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

            return(View(employee));
        }
Example #4
0
        public IActionResult Create(EmployeeEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var employee = new Employee();
                employee.Name = model.Name;
                SQLEmployeeData sqlData = new SQLEmployeeData(_netCoreDBContext);
                sqlData.add(employee);

                return(RedirectToAction("Detail", new { Id = employee.ID }));
            }
            return(View());
        }
Example #5
0
        public IActionResult Edit(int Id, EmployeeEditViewModel model)
        {
            SQLEmployeeData sqlData  = new SQLEmployeeData(_netCoreDBContext);
            Employee        employee = sqlData.Get(Id);

            if (employee != null && ModelState.IsValid)
            {
                employee.Name = model.Name;
                _netCoreDBContext.SaveChanges();
                return(RedirectToAction("Detail", new { Id = employee.ID }));
            }

            return(View(employee));
        }