コード例 #1
0
        public ActionResult Edit(int id)
        {
            demodbEntities  con = new demodbEntities();
            DemotblEmployee emp = con.DemotblEmployees.FirstOrDefault(x => x.Id.Equals(id));

            return(View(emp));
        }
コード例 #2
0
        public ActionResult Delete(DemotblEmployee emp)
        {
            demodbEntities con = new demodbEntities();

            con.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
            con.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            demodbEntities  con = new demodbEntities();
            DemotblEmployee selectedEmployee =
                con.DemotblEmployees.FirstOrDefault(x => x.Id == id);

            return(View(selectedEmployee));
        }
コード例 #4
0
        public ActionResult Create(DemotblEmployee emp)
        {
            demodbEntities con = new demodbEntities();

            con.DemotblEmployees.Add(emp);
            con.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
コード例 #5
0
        public ActionResult Edit(DemotblEmployee demoemp)
        {
            demodbEntities con = new demodbEntities();

            //DemotblEmployee emp = con.DemotblEmployees.FirstOrDefault(x => x.Id.Equals(demoemp.Id));
            //emp.FullName = demoemp.FullName;
            //emp.Gender = demoemp.Gender;
            //emp.Age = demoemp.Age;
            //emp.EmailAddress = demoemp.EmailAddress;
            //emp.HireDate = demoemp.HireDate;
            //emp.Salary = demoemp.Salary;
            //emp.PersonalWebSite = demoemp.PersonalWebSite;
            con.Entry(demoemp).State = System.Data.Entity.EntityState.Modified;
            con.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        // GET: Home
        public ActionResult Index()
        {
            demodbEntities context = new demodbEntities();

            return(View(context.DemotblEmployees.ToList()));
        }