Ejemplo n.º 1
0
        public async Task <EmployeeAvailabilityModel> GetEmployeeAvailabilityAsync(string userId)
        {
            var userClient = _clientFactory.CreateUserClient(_options, userId);

            var response = await userClient.GetUserShiftPreferenceAsync(userId).ConfigureAwait(false);

            return(_availabilityMap.MapAvailability(response.Availability, userId));
        }
Ejemplo n.º 2
0
        public override async Task <IActionResult> HandleRequest(ChangeRequest changeRequest, ChangeItemRequest changeItemRequest, ChangeResponse changeResponse, string userId, ILogger log, IDurableOrchestrationClient starter)
        {
            var preferenceRequest = changeItemRequest.Body.ToObject <ShiftPreferenceResponse>();

            if (preferenceRequest == null)
            {
                return(new ChangeErrorResult(changeResponse, ErrorCodes.ChangeRequestNotFound, _stringLocalizer[ErrorCodes.ChangeRequestNotFound]));
            }

            var employee = await _cacheService.GetKeyAsync <EmployeeModel>(ApplicationConstants.TableNameEmployees, userId).ConfigureAwait(false);

            if (employee == null)
            {
                return(new ChangeErrorResult(changeResponse, ErrorCodes.UserCredentialsNotFound, _stringLocalizer[ErrorCodes.UserCredentialsNotFound]));
            }

            // get the conection object which contains TimeZoneInfoId to populate below availabilityModel.
            var connection = await _scheduleConnectorService.GetConnectionAsync(employee.TeamIds[0]).ConfigureAwait(false);

            // map the preference request to an availability model
            var availabilityModel = _availabilityMap.MapAvailability(preferenceRequest.Availability, userId);

            availabilityModel.WfmEmployeeId  = employee.WfmEmployeeId;
            availabilityModel.TimeZoneInfoId = connection.TimeZoneInfoId;

            var wfmResponse = await _wfmActionService.UpdateEmployeeAvailabilityAsync(availabilityModel, log).ConfigureAwait(false);

            return(WfmResponseToActionResult(wfmResponse, changeItemRequest, changeResponse));
        }