예제 #1
0
 public ActionResult Edit([Bind(Include = "empid,empname,email,phoneno")] employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
예제 #2
0
 public bool DeleteEmployee(int id)
 {
     using (var context = new empdbEntities())
     {
         var emp = new Employee()
         {
             Id = id
         };
         context.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
         return(false);
     }
 }
예제 #3
0
 public bool UpdateEmployee(int id, EmployeeModels models)
 {
     using (var context = new empdbEntities())
     {
         var employee = new Employee();
         if (employee != null)
         {
             employee.FirstName = models.FirstName;
             employee.LastName  = models.LastName;
             employee.Email     = models.Email;
             employee.Code      = models.Code;
             employee.Addressid = models.Addressid;
         }
         context.Entry(employee).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return(true);
     }
 }