/// <summary> /// Christian Lopez /// Created 2017/02/24 /// /// </summary> /// <param name="userName"></param> /// <returns></returns> public Employee RetrieveEmployeeByUserName(string userName) { try { return(EmployeeAccessor.RetrieveEmployeeByUsername(userName)); } catch (SqlException ex) { throw new ApplicationException("There was a database error.", ex); } catch (Exception ex) { throw new ApplicationException("There was an unknown error.", ex); } }
/// <summary> /// Retrieves Employee from database using Employee Id or User Id /// </summary> /// <param name="username">Paramter used to extract Employee Details</param> /// <returns>Employee Object Containing All Details</returns> public Employee RetrieveEmployeeByUsername(string username) { var employee = new Employee(); //Retrieve all employee information try { var allUserDataInDB = EmployeeAccessor.RetrieveEmployeeByUsername(username); employee.UserId = allUserDataInDB.UserId; employee.Username = allUserDataInDB.Username; employee.FirstName = allUserDataInDB.FirstName; employee.LastName = allUserDataInDB.LastName; employee.OtherNames = allUserDataInDB.OtherNames; employee.DepartmentId = allUserDataInDB.DepartmentId; employee.Department = allUserDataInDB.Department; employee.PhoneNumber = allUserDataInDB.PhoneNumber; employee.Email = allUserDataInDB.Email; employee.PicUrl = allUserDataInDB.PicUrl; employee.isEmployed = allUserDataInDB.isEmployed; employee.isBlocked = allUserDataInDB.isBlocked; employee.UserRolesId = allUserDataInDB.UserRolesId; employee.JobDesignation = allUserDataInDB.JobDesignation; employee.ClearanceLevelId = allUserDataInDB.ClearanceLevelId; employee.ClearanceLevel = allUserDataInDB.ClearanceLevel; //employee.PersonalInfoId = allUserDataInDB.PersonalInfoId; employee.Gender = allUserDataInDB.Gender; employee.DateOfBirth = allUserDataInDB.DateOfBirth; employee.CountryId = allUserDataInDB.CountryId; employee.Nationality = allUserDataInDB.Nationality; employee.AdditonalInfo = allUserDataInDB.AdditonalInfo; employee.Address = allUserDataInDB.Address; //this is a list employee.HireDate = allUserDataInDB.HireDate; employee.MaritalStatus = allUserDataInDB.MaritalStatus; employee.PersonalEmail = allUserDataInDB.PersonalEmail; employee.PersonalPhoneNumber = allUserDataInDB.PersonalPhoneNumber; } catch (Exception) { throw; } return(employee); }