Beispiel #1
0
 internal bool IsExistingEmployee(int employeeID)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         return(context.tblEmployees.Any(e => e.EmployeeID == employeeID));
     }
 }
Beispiel #2
0
 internal void AddNewEmployee(tblEmployee employee)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblEmployees.Add(employee);
         context.SaveChanges();
     }
 }
Beispiel #3
0
 public void AddNewLocation(tblLocation location)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblLocations.Add(location);
         context.SaveChanges();
     }
 }
Beispiel #4
0
 internal void AddNewSector(tblSector newSector)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         context.tblSectors.Add(newSector);
         context.SaveChanges();
     }
 }
Beispiel #5
0
 internal tblEmployee LoadEmployee(int employeeID)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         if (context.tblEmployees.Any(e => e.EmployeeID == employeeID))
         {
             return(context.tblEmployees.First(e => e.EmployeeID == employeeID));
         }
         return(new tblEmployee());
     }
 }
Beispiel #6
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();
         }
     }
 }
Beispiel #7
0
 internal List <string> LoadRegistrationNumbers()
 {
     using (var context = new EmployeeRecordsEntities())
     {
         var registrationNumbers = new List <string>();
         if (context.tblEmployees.Any())
         {
             foreach (var item in context.tblEmployees)
             {
                 registrationNumbers.Add(item.RegistrationNumber);
             }
             return(registrationNumbers);
         }
         return(registrationNumbers);
     }
 }
Beispiel #8
0
 internal List <string> LoadPersonalNumbers()
 {
     using (var context = new EmployeeRecordsEntities())
     {
         var personalNumbers = new List <string>();
         if (context.tblEmployees.Any())
         {
             foreach (var item in context.tblEmployees)
             {
                 personalNumbers.Add(item.PersonalNo);
             }
             return(personalNumbers);
         }
         return(personalNumbers);
     }
 }
Beispiel #9
0
        public List <tblLocation> LoadLocations()
        {
            using (var context = new EmployeeRecordsEntities())
            {
                var locations = new List <tblLocation>();

                if (context.tblLocations.Any())
                {
                    foreach (var item in context.tblLocations)
                    {
                        locations.Add(item);
                    }
                    return(locations.OrderBy(o => o.Adress).ToList());
                }
                return(locations);
            }
        }
Beispiel #10
0
        internal List <tblSector> LoadSectors()
        {
            using (var context = new EmployeeRecordsEntities())
            {
                var sectors = new List <tblSector>();

                if (context.tblSectors.Any())
                {
                    foreach (var item in context.tblSectors)
                    {
                        sectors.Add(item);
                    }
                    return(sectors);
                }
                return(sectors);
            }
        }
Beispiel #11
0
        public List <vwEmployee> LoadEmployees()
        {
            using (var context = new EmployeeRecordsEntities())
            {
                var employees = new List <vwEmployee>();

                if (context.vwEmployees.Any())
                {
                    foreach (var item in context.vwEmployees)
                    {
                        employees.Add(item);
                    }
                    return(employees);
                }
                return(employees);
            }
        }
Beispiel #12
0
 internal List <string> LoadManagers(int employeeID)
 {
     using (var context = new EmployeeRecordsEntities())
     {
         var managers = new List <string>();
         if (context.tblEmployees.Any())
         {
             foreach (var item in context.tblEmployees)
             {
                 if (item.EmployeeID != employeeID)
                 {
                     managers.Add(item.GivenName + " " + item.Surname);
                 }
             }
             return(managers);
         }
         return(managers);
     }
 }
Beispiel #13
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();
                }
            }
        }