예제 #1
0
 public string AddEmployee(EmployeeDetail employee)
 {
     using (var repo = new EmployeeInterviewEntities())
     {
         repo.EmployeeDetails.Add(employee);
         repo.SaveChanges();
     }
     return("Employee Added successfully.");
 }
예제 #2
0
 public string DeleteEmployee(int id)
 {
     using (var repo = new EmployeeInterviewEntities())
     {
         var data = repo.EmployeeDetails.FirstOrDefault(a => a.Id == id);
         if (data != null)
         {
             repo.EmployeeDetails.Remove(data)
             ;
             repo.SaveChanges();
         }
     }
     return("Employee removed successfully.");
 }
예제 #3
0
 public string UpdateEmployee(EmployeeDetail employee)
 {
     using (var repo = new EmployeeInterviewEntities())
     {
         var data = repo.EmployeeDetails.SingleOrDefault(a => a.Id == employee.Id);
         if (data != null)
         {
             data.FirstName    = employee.FirstName;
             data.LastName     = employee.LastName;
             data.PhoneNumber  = employee.PhoneNumber;
             data.EmailAddress = employee.EmailAddress;
             data.Address      = employee.Address;
             repo.SaveChanges();
         }
     }
     return("Employee Updated successfully.");
 }