Esempio n. 1
0
 public IActionResult Details(int id)
 {
     using (var context = new FirstAppDemoDbContext())
     {
         SQLEmployeeData sqlData  = new SQLEmployeeData(_context);
         var             employee = sqlData.Get(id);
         if (employee == null)
         {
             return(RedirectToAction("Index"));
         }
         return(View(employee));
     }
 }
Esempio n. 2
0
        public ViewResult Index()
        {
            var model = new HomePageViewModel();

            /*var Employees = new Employee { Name = "tung" };*/
            using (var context = new FirstAppDemoDbContext())
            {
                SQLEmployeeData sqlData = new SQLEmployeeData(_context);
                /*sqlData.Add(Employees);*/
                model.Employees = sqlData.GetAll();
            }

            return(View(model));
        }
Esempio n. 3
0
 public IActionResult Edit(int id, EmployeeEditViewModel input)
 {
     using (var context = new FirstAppDemoDbContext())
     {
         SQLEmployeeData sqlData  = new SQLEmployeeData(_context);
         var             employee = sqlData.Get(id);
         if (employee != null && ModelState.IsValid)
         {
             employee.Name = input.Name;
             _context.SaveChanges();
             return(RedirectToAction("Details", new { id = employee.ID }));
         }
         return(View(employee));
     }
 }