Example #1
0
 public void AddNewLocation(tblLocation location)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblLocations.Add(location);
         context.SaveChanges();
     }
 }
Example #2
0
 internal void AddNewSector(tblSector newSector)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblSectors.Add(newSector);
         context.SaveChanges();
     }
 }
Example #3
0
 internal void AddNewEmployee(tblEmployee employee)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblEmployees.Add(employee);
         context.SaveChanges();
     }
 }
Example #4
0
 internal void DeleteEmployee(int employeeID)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         var employeeToRemove = context.tblEmployees.FirstOrDefault(e => e.EmployeeID == employeeID);
         if (employeeToRemove != null)
         {
             context.tblEmployees.Remove(employeeToRemove);
             context.SaveChanges();
         }
     }
 }
Example #5
0
        internal void UpdateEmployee(int employeeID, tblEmployee employee)
        {
            using (var context = new EmployeeRecordsEntities())
            {
                if (context.tblEmployees.Any(e => e.EmployeeID == employeeID))
                {
                    var employeeToUpdate = context.tblEmployees.First(e => e.EmployeeID == employeeID);
                    employeeToUpdate.GivenName          = employee.GivenName;
                    employeeToUpdate.Surname            = employee.Surname;
                    employeeToUpdate.Sex                = employee.Sex;
                    employeeToUpdate.PersonalNo         = employee.PersonalNo;
                    employeeToUpdate.RegistrationNumber = employee.RegistrationNumber;
                    employeeToUpdate.Telephone          = employee.Telephone;
                    employeeToUpdate.LocationID         = employee.LocationID;
                    employeeToUpdate.Manager            = employee.Manager;
                    employeeToUpdate.SectorID           = employee.SectorID;

                    context.SaveChanges();
                }
            }
        }