public CustomIdentityDTO SaveIdentity(AuthorizeLogOnDTO customIdentity)
        {
            using (var ctx = new Entities())
            {
                ctx.Database.Connection.Open();
                var employee = ctx.Employees.SingleOrDefault(e => e.ADName == customIdentity.UserName);
                if (employee == null)
                {
                    employee = new Employee();
                    LoadEmployee(employee, customIdentity);
                    employee.AwardPayoutThreshold = EmployeeConstants.DefaultAwardPayoutThreshold;
                    ctx.Employees.Add(employee);
                }
                else
                {
                    LoadEmployee(employee, customIdentity);
                }
                ctx.SaveChanges();

                AttachAndSavePermission(ctx, employee.EmployeeId, Common.Enums.PermissionType.User);

                return new CustomIdentityDTO
                {
                    Id = employee.EmployeeId,
                    ADName = employee.ADName
                };
            }
        }
 private static Employee LoadData(AccountInfoEditDTO data)
 {
     var employeeEntity = new Employee
     {
         EmployeeId = data.EmployeeId,
         ADName = data.UserName,
         AwardPayoutThreshold = data.PointPayoutThreshold
     };
     return employeeEntity;
 }
 private void LoadEmployee(Employee employee, AuthorizeLogOnDTO customIdentity)
 {
     employee.ADName = customIdentity.UserName;
     employee.FirstName = customIdentity.FirstName;
     employee.LastName = customIdentity.LastName;
     employee.EmploymentStartDate = customIdentity.EmployementStartDate;
     employee.EmploymentEndDate = customIdentity.EmployementEndDate;
 }