Beispiel #1
0
 // Try to login a user with the providen data
 public static bool Login(string username, string password)
 {
     bool result = false;
     var request = new UserRequest();
     request.UserName = username;
     request.Password = password;
     var accountFound = new UserFactory().GetUserByLogin(request).UserAccount;
     if (accountFound != null)
     {
         saveUserInSession(accountFound);
         result = true;
     }
     return result;
 }
Beispiel #2
0
 public UserResponse getEmployeeByUserId(UserRequest request)
 {
     UserResponse response = new UserResponse();
     var employeeFound = Olympus._Enterprise.Employees.Where(x => x.UserAccountId == request.UserAccount.Id).SingleOrDefault();
     if (employeeFound != null)
     {
         var person = employeeFound.Person;
         Olympus._Enterprise.Detach(person);
         Olympus._Enterprise.Detach(employeeFound);
         response.Employee = Mapper.Map<Employee, EmployeeDto>(employeeFound);
         response.Employee.Person = Mapper.Map<Person, PersonDto>(person);
     }
     return response;
 }
Beispiel #3
0
        public UserResponse getUserByLogin(UserRequest request)
        {
            UserResponse response = new UserResponse();
            var accountFound = Olympus._Nerv.UserAccounts.Where(x => x.Account.ToUpper() == request.UserName.ToUpper()).SingleOrDefault();

            if (accountFound != null)
            {
                var cypher = new Cryptos(Cryptos.algorithmType.DES);
                if (cypher.Encrypt(request.Password).Equals(accountFound.Password))
                {
                    // Map the UserAccount
                    Olympus._Nerv.UserAccounts.Detach(accountFound);
                    response.UserAccount = Mapper.Map<UserAccount, UserAccountDto>(accountFound);
                }
            }
            return response;
        }
Beispiel #4
0
        private static EmployeeSession getEmployeeSession(UserSessionData userSession)
        {
            EmployeeSession employeeFromUser = new EmployeeSession();
            var userAccount = new UserAccountDto() { Id = userSession.UserId};
            var request = new UserRequest() { UserAccount = userAccount };

            var employeeFound = new UserFactory().GetEmployeeByUserId(request).Employee;

            if (employeeFound != null)
            {
                employeeFromUser.Id = employeeFound.Id;
                employeeFromUser.Name = employeeFound.Person.Name;
                employeeFromUser.LastName = employeeFound.Person.LastName;
            }
            return employeeFromUser;
        }
Beispiel #5
0
 public UserResponse GetUserByLogin(UserRequest request)
 {
     return _userService.getUserByLogin(request);
 }
Beispiel #6
0
 public UserResponse GetEmployeeByUserId(UserRequest request)
 {
     return _userService.getEmployeeByUserId(request);
 }