public SendRequestStatusRS SendRequestStatus(string sessionId, string requestId, string flightNumber, string flightTime) { SendRequestStatusRS response = new SendRequestStatusRS() {IsSuccess = true}; using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); try { IRequestProvider requestProvider = RequestProviderFactory.GetRequestProvider(); IEmailProvider emailProvider = EmailProviderFactory.GetEmailProvider(); Model.FlightRequest request = requestProvider.GetProcessedRequest(requestId); ITokenProvider tokenProvider = TokenProviderFactory.GetTokenProvider(); if (request == null) { response.IsSuccess = false; response.ErrorMessage = "Request not found!!!"; } try { string token = string.Empty; if(request.Status == RequestStatus.Accepted || request.Status == RequestStatus.IncreaseBid) { decimal payableamount = 0; if(request.Status == RequestStatus.Accepted) { payableamount = request.RequesterBidAmount * request.Passengers.Count; } else { payableamount = request.AirlineBidAmount * request.Passengers.Count; } token = tokenProvider.GenerateToken(request.Email, request.FirstName, request.Mobile, request.Passengers.Count, payableamount, request.RequestId); } string tokenUrl = Configuration.PaymentTokenBaseUrl + "?token=" + token; bool isEmailSent = emailProvider.SendRequestStatusEmail(request, flightNumber, flightTime, tokenUrl); if (isEmailSent) { string errorMessage = string.Empty; bool isEmailSentStatusUpdated = requestProvider.UpdateRequestEmailSentStatus(request.RequestId, isEmailSent,out errorMessage); if (!isEmailSentStatusUpdated || !string.IsNullOrEmpty(errorMessage)) { throw new Exception(errorMessage); } } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = exception.Message; Logger.LogException(exception, Source, "SendRequestStatus", Severity.Critical); } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = exception.Message; Logger.LogException(exception, Source, "SendRequestStatus", Severity.Critical); } } return response; }
public SendRequestStatusRS SendRequestStatus(string sessionId, string requestId, string flightNumber, string flightTime) { SendRequestStatusRS response = new SendRequestStatusRS() { IsSuccess = true }; using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); try { var channelFactory = new WebChannelFactory<IAirlinesAdminServiceRest>( Configuration.AirlinesAdminServiceConfigurationName); IAirlinesAdminServiceRest channel = channelFactory.CreateChannel(); if (channel is IContextChannel) using (new OperationContextScope(channel as IContextChannel)) { WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "SendRequestStatus"); response = channel.SendRequestStatus(sessionId, requestId, flightNumber, flightTime); return response; } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = exception.Message; Logger.LogException(exception, Source, "SendRequestStatus", Severity.Major); } } return response; }