public SaveProcessedFlightRequestsRS SaveProcessedFlightRequests(string sessionId, SaveProcessedFlightRequestsRQ request)
 {
     SaveProcessedFlightRequestsRS response = new SaveProcessedFlightRequestsRS() { IsSuccess = true, };
     if (request == null || request.ProcessedRequests == null || request.ProcessedRequests.Count == 0)
     {
         response.IsSuccess = false;
         response.ErrorMessage = "Invalid request or no processed requests found!!!";
         return response;
     }
     using (new ApplicationContextScope(new ApplicationContext()))
     {
         ApplicationContext.SetSessionId(sessionId);
         IRequestProvider requestProvider = RequestProviderFactory.GetRequestProvider();
         foreach (DataContract.FlightRequest flightRequest in request.ProcessedRequests)
         {
             string errorMessage = string.Empty;
             bool isSuccess = IsValidAirlineAction(flightRequest, out errorMessage);
             if (isSuccess)
             {
                 try
                 {
                     isSuccess = requestProvider.SaveProcessedRequest(flightRequest.ToModel(), out errorMessage);
                 }
                 catch (Exception exception)
                 {
                     isSuccess = false;
                     errorMessage = exception.Message;
                     Logger.LogException(exception, Source, "SaveProcessedFlightRequests", Severity.Critical);
                 }
             }
             if (!isSuccess || !string.IsNullOrEmpty(errorMessage))
             {
                 response.IsSuccess = false;
                 response.FailedRequests = response.FailedRequests ?? new List<FailedRequest>();
                 response.FailedRequests.Add(new FailedRequest()
                 {
                     RequestId = flightRequest.RequestId,
                     ErrorMessage = errorMessage
                 });
             }
         }
     }
     //Send email notifications about the airline status.
     Task.Factory.StartNew(() => SendAllProcessedRequestStatus(sessionId));
     return response;
 }
        public SaveProcessedFlightRequestsRS SaveProcessedFlightRequests(string sessionId, SaveProcessedFlightRequestsRQ request)
        {
            SaveProcessedFlightRequestsRS response = new SaveProcessedFlightRequestsRS() { 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", "SaveProcessedFlightRequests");
                            response = channel.SaveProcessedFlightRequests(sessionId, request);
                            return response;
                        }
                }
                catch (Exception exception)
                {
                    response.IsSuccess = false;
                    response.ErrorMessage = exception.Message;
                    Logger.LogException(exception, Source, "SaveProcessedFlightRequests", Severity.Major);
                }
            }
            return response;
        }