Esempio n. 1
0
        public ActionResult NewEmployee(EmpTable emp)
        {
            var context = new LnTTrainingEntities();

            context.EmpTables.Add(emp);
            context.SaveChanges();
            return(RedirectToAction("AllEmployees"));
        }
Esempio n. 2
0
        public ActionResult Find(EmpTable emp)
        {
            var context = new LnTTrainingEntities();
            var model   = context.EmpTables.FirstOrDefault((e) => e.EmpID == emp.EmpID);

            model.EmpName    = emp.EmpName;
            model.EmpAddress = emp.EmpAddress;
            model.EmpSalary  = emp.EmpSalary;
            context.SaveChanges();//Commits the changes made to the records...
            return(RedirectToAction("AllEmployees"));
        }
Esempio n. 3
0
        public ActionResult Delete(string id, string conformbutton)
        {
            //convert string to int
            int empId   = int.Parse(id);
            var context = new LnTTrainingEntities();
            var model   = context.EmpTables.FirstOrDefault((e) => e.EmpID == empId);

            context.EmpTables.Remove(model);
            context.SaveChanges();
            Console.WriteLine("Thank you!");
            return(RedirectToAction("AllEmployees"));
        }