Exemplo n.º 1
0
        public ViewResult AllEmployees()
        {
            var context = new TrialllEntities();
            var model   = context.MyTables.ToList();

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult NewEmployee(MyTable emp)
        {
            var context = new TrialllEntities();

            context.MyTables.Add(emp);
            context.SaveChanges();
            return(RedirectToAction("AllEmployees"));
        }
Exemplo n.º 3
0
        public ViewResult Find(string id)
        {
            int empId   = int.Parse(id);
            var context = new TrialllEntities();
            var model   = context.MyTables.FirstOrDefault((e) => e.Id == empId);

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Delete(string id)
        {
            //convert string to int
            int empId   = int.Parse(id);
            var context = new TrialllEntities();
            var model   = context.MyTables.FirstOrDefault((e) => e.Id == empId);

            context.MyTables.Remove(model);
            context.SaveChanges();
            return(RedirectToAction("AllEmployees"));
        }
Exemplo n.º 5
0
        public ActionResult Find(MyTable emp)
        {
            var context = new TrialllEntities();
            var model   = context.MyTables.FirstOrDefault((e) => e.Id == emp.Id);

            model.Name = emp.Name;
            //model.EmpAddress = emp.EmpAddress;
            //model.EmpSalary = emp.EmpSalary;
            context.SaveChanges();//Commits the changes made to the records...
            return(RedirectToAction("AllEmployees"));
        }