public async Task <GetAppointmentSlotsResponse> GetAppointmentSlots(GetAppointmentSlotsRequest getAppointmentSlotsRequest) { if (getAppointmentSlotsRequest == null) { throw new ArgumentNullException(nameof(getAppointmentSlotsRequest)); } var validateMessages = _validateRequest.ValidateRequestData(getAppointmentSlotsRequest); if (validateMessages != null) { throw new InvalidRequestException(validateMessages.AsEnumerable().ToList()); } var customer = _cdkCustomerDAL.GetCdkCustomer(getAppointmentSlotsRequest.CommunityId, getAppointmentSlotsRequest.CustomerNo); if (customer == null) { throw new InvalidCustomerException(ExceptionMessages.InvalidCustomer); } // if token is null then requesting for new token. // Otherwise used the stored token in database. var startTime = DateTime.Now; var timer = System.Diagnostics.Stopwatch.StartNew(); var customerToken = await _tokenService.GetCustomerToken(customer, getAppointmentSlotsRequest.RooftopId); _telemetryClient?.TrackDependency("CDKAutolineService", "GetCustomerToken", customer.CustomerLoginId, startTime, timer.Elapsed, customerToken != null); startTime = DateTime.Now; timer = System.Diagnostics.Stopwatch.StartNew(); var cdkGetAppointmentSlotsRequest = MapAppointmentSlots(getAppointmentSlotsRequest); var getServiceAdvisorsResponse = await RequestGetAppointmentSlots(cdkGetAppointmentSlotsRequest, getAppointmentSlotsRequest.CommunityId, customer.CustomerLoginId, customerToken); _telemetryClient?.TrackDependency("CDKAutolineService", "GetAppointmentSlots", JsonConvert.SerializeObject(cdkGetAppointmentSlotsRequest), startTime, timer.Elapsed, getServiceAdvisorsResponse != null); if (getServiceAdvisorsResponse == null || !getServiceAdvisorsResponse.Success) { var cdkAutolineException = new CDKAutolineException(UtilityHelper.SerializeObject(getServiceAdvisorsResponse?.Errors)); _telemetryClient?.TrackException(cdkAutolineException); throw cdkAutolineException; } return(getServiceAdvisorsResponse.Result as GetAppointmentSlotsResponse); }
internal CDKGetAppointmentSlotsRequest MapAppointmentSlots(GetAppointmentSlotsRequest request) { return(_mapper.Map <GetAppointmentSlotsRequest, CDKGetAppointmentSlotsRequest>(request)); }