public async Task <IActionResult> getCurrentEmployee(bool getAD = false)
        {
            // if(this.HostingEnvironment.EnvironmentName== Environments.Development)
            if (CurrentUser == "ENERGY\\d.khudairi.c" || CurrentUser == "ENERGY\\r.draiwaish.c")
            {
                getAD = true;
            }
            Employee employeedata = new Employee();

            try
            {
                employeedata = await EmployeeService.FindEmployeeWithEmailAsync(CurrentUserEmail);
            }
            catch {
                Logger.LogDebug($"can not get data for this email : {CurrentUserEmail}");
            }
            if (getAD)
            {
                var ademployee = await ADService.GetDataFromAD(CurrentUserEmail);

                var employee = Mapper.Map <Employee>(ademployee);
                Mapper.Map <ADService.ADReturned, Employee>(ademployee, employeedata);
                employeedata.Email = CurrentUserEmail;
            }
            return(Ok(employeedata));
        }
Beispiel #2
0
        public async Task <Employee> GetCreationEmployeeData(string email)
        {
            var employeedata = await employeeService.FindEmployeeWithEmailAsync(email);

            Employee employee = null;

            if (employeedata == null)
            {
                var adData = await ADService.GetDataFromAD(email);

                employee = Mapper.Map <Employee>(adData);
            }
            else
            {
                employee = Mapper.Map <Employee>(employeedata);
            }
            return(employee);
        }
        public async Task <Employee> GetResignedEmployeeData(string email)
        {
            var employeedata = await employeeService.GetEmployeeFromREST(email);

            Employee employee = null;

            if (employeedata == null)
            {
                var adData = await ADService.GetDataFromAD(email);

                employee = Mapper.Map <Employee>(adData);
            }
            else
            {
                employee = Mapper.Map <Department, Employee>(employeedata.Department);
                Mapper.Map <EmployeeRest, Employee>(employeedata, employee);
                return(employee);
            }
            return(employee);
        }