Esempio n. 1
0
 internal vwEmployee FindEmployeeCredentials(string userName, string password)
 {
     try
     {
         using (HotelServiceEntities context = new HotelServiceEntities())
         {
             string     encryptedPassword = EncryptionHelper.Encrypt(password);
             vwEmployee adminToFind       = (from e in context.vwEmployees where e.UserName == userName && e.Password == encryptedPassword select e).First();
             return(adminToFind);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Employee not found." + ex.Message.ToString());
         return(null);
     }
 }
Esempio n. 2
0
 internal vwEmployee EditEmployeeSalary(vwEmployee employee)
 {
     try
     {
         using (HotelServiceEntities context = new HotelServiceEntities())
         {
             tblEmployee employeeSalaryToEdit = (from e in context.tblEmployees where e.EmployeeID == employee.EmployeeID select e).First();
             employeeSalaryToEdit.Salary = employee.Salary;
             context.SaveChanges();
             return(employee);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
Esempio n. 3
0
 internal vwEmployee AddEmployee(vwEmployee employee)
 {
     try
     {
         using (HotelServiceEntities context = new HotelServiceEntities())
         {
             tblUser newUser = new tblUser
             {
                 FullName    = employee.FullName,
                 DateOfBirth = employee.DateOfBirth,
                 Email       = employee.Email,
                 UserName    = employee.UserName,
                 Password    = employee.Password
             };
             context.tblUsers.Add(newUser);
             context.SaveChanges();
             employee.UserID = newUser.UserID;
             tblEmployee newEmployee = new tblEmployee
             {
                 FloorNumber = employee.FloorNumber,
                 Gender      = employee.Gender,
                 Citizenship = employee.Citizenship,
                 WorkType    = employee.WorkType,
                 UserID      = employee.UserID
             };
             context.tblEmployees.Add(newEmployee);
             context.SaveChanges();
             employee.EmployeeID = newEmployee.EmployeeID;
             return(employee);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }