Exemplo n.º 1
0
        public string AddRequestSessionData(string sessionId, Request request)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<ISessionServiceRest>(Configuration.SessionServiceConfigurationName);
                    ISessionServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName",
                                                                                    "AddRequestSessionData");
                            return channel.AddRequestSessionData(sessionId, request);
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "AddRequestSessionData", Severity.Major);
                }
            }
            return null;
        }
Exemplo n.º 2
0
        public AddRequestResponse AddRequest(string sessionId, Request request)
        {
            IRequestProvider requestProvider = RequestProviderFactory.GetRequestProvider();
            var response = new AddRequestResponse();

            try
            {
                Core.Model.Request modelRequest = request.ToModel();

                IAccountProvider accountProvider = AccountProviderFactory.GetAccountProvider();
                Account account = accountProvider.GetAccount(request.AccountId);

                if (account != null)
                {
                    string errorMessage;
                    modelRequest = requestProvider.AddRequest(modelRequest, out errorMessage);

                    IEmailProvider emailProvider = EmailProviderFactory.GetEmailProvider();

                    if (modelRequest != null)
                    {
                        response.IsSuccess = true;
                        response.Id = modelRequest.RequestId;
                        response.Order = modelRequest.WaitListPosition;
                        response.UniqueNumber = modelRequest.FriendlyRequestId;

                        emailProvider.SendWLEmail(account.Email, modelRequest.RequestId, modelRequest.FriendlyRequestId,
                                                  modelRequest.TravelDate,
                                                  modelRequest.FromAirport, modelRequest.ToAirport,
                                                  modelRequest.Passengers);
                        Task.Factory.StartNew(() => AddPassengersInTravellerlist(sessionId, modelRequest));
                    }
                    else
                    {
                        response.ErrorMessage = errorMessage;
                    }
                }
                else
                {
                    response.ErrorMessage = "Account invalid. Please try again.";
                }
            }
            catch (Exception exception)
            {
                response.ErrorMessage = "Something is not quite right here. Please try again later.";

                Logger.LogException(exception, Source, "AddRequest", Severity.Major);
            }
            return response;
        }
Exemplo n.º 3
0
        public string AddRequestSessionData(string sessionId, Request request)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.SetSessionId(sessionId);
                try
                {
                    ISessionProvider sessionProvider = SessionProviderFactory.GetSessionProvider();

                    return
                        sessionProvider.AddRequestToSession(new Core.Model.SessionData
                                                          {SessionId = sessionId, Request = request.ToModel()});
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "AddRequestSessionData", Severity.Trace);
                    return string.Empty;
                }
            }
        }
Exemplo n.º 4
0
        public SearchResponse BeginSearch(string sessionId, Request request)
        {
            IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider();
            var response = new SearchResponse();

            try
            {
                Core.Model.Request modelRequest = request.ToModel();
                string errorMessage;
                string searchId = flightProvider.BeginSearch(modelRequest.FromAirport, request.ToAirport,
                                                             modelRequest.TravelDate,
                                                             modelRequest.Passengers.GetAdultCount(),
                                                             modelRequest.Passengers.GetChildCount(),
                                                             modelRequest.Passengers.GetInfantCount(), out errorMessage);
                if (!string.IsNullOrEmpty(searchId) && string.IsNullOrEmpty(errorMessage))
                {
                    response.IsSuccess = true;
                    response.IsComplete = false;
                    response.SearchId = searchId;
                }
                else
                {
                    response.ErrorMessage = errorMessage;
                }
            }
            catch (Exception exception)
            {
                response.ErrorMessage = "Something is not quite right here. Please try again later.";

                Logger.LogException(exception, Source, "BeginSearch", Severity.Major);
            }
            return response;
        }
Exemplo n.º 5
0
        public UpdateRequestResponse UpdateRequest(string authenticationId, string sessionId, Request request)
        {
            var response = new UpdateRequestResponse { IsSuccess = true };
            try
            {
                IAuthenticationProvider authProvider = AuthenticationProviderFactory.GetAuthenticationProvider();
                IAccountProvider accountProvider = AccountProviderFactory.GetAccountProvider();
                if (authProvider.Validate(authenticationId))
                {
                    string accountId = authProvider.GetAccountId(authenticationId);

                    if (!string.IsNullOrEmpty(accountId))
                    {
                        Account account = accountProvider.GetAccount(accountId);

                        request.AccountId = accountId;
                        IRequestProvider requestProvider = RequestProviderFactory.GetRequestProvider();
                        string errorMessage;
                        var modelRequest = request.ToModel();
                        Core.Model.Request oldRequest = requestProvider.GetRequest(accountId, modelRequest.RequestId);
                        Core.Model.Request updatedRequest = requestProvider.UpdateRequest(modelRequest,
                                                                                          out errorMessage);
                        if (updatedRequest == null || !string.IsNullOrEmpty(errorMessage))
                        {
                            response.IsSuccess = false;
                            response.ErrorMessage = errorMessage;
                        }
                        else
                        {
                            if(oldRequest!=null)
                            {
                                if(oldRequest.BidAmount < updatedRequest.BidAmount || oldRequest.Passengers.Count < updatedRequest.Passengers.Count)
                                {
                                    bool result = requestProvider.UpdateRequestStatus(oldRequest.RequestId,
                                                                                  RequestStatus.New.ToString(),
                                                                                  out errorMessage);
                                }
                            }
                            IEmailProvider emailProvider = EmailProviderFactory.GetEmailProvider();

                            emailProvider.SendWLEmail(account.Email, updatedRequest.RequestId,
                                                      updatedRequest.FriendlyRequestId,
                                                      updatedRequest.TravelDate,
                                                      updatedRequest.FromAirport, updatedRequest.ToAirport,
                                                      updatedRequest.Passengers);

                            response.Request = updatedRequest.ToDataContract();
                            Task.Factory.StartNew(() => AddPassengersInTravellerlist(sessionId, request.ToModel()));
                        }
                    }
                    else
                    {
                        response.IsSuccess = false;
                        response.ErrorMessage = "Account not found! Please SignIn or SingUp";
                    }
                }
                else
                {
                    response.IsSuccess = false;
                    response.ErrorMessage = "Session expired. Please login again!";
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex, Source, "UpdateRequest", Severity.Major);
                response.IsSuccess = false;
                response.ErrorMessage = ex.ToString();
            }
            return response;
        }
Exemplo n.º 6
0
 public string[] SaveRequest(Request request)
 {
     var requestProvider = new RequestDataProvider();
     Core.Model.Request response = requestProvider.SaveRequest(request.ToModel());
     return new[] {response.RequestId, response.FriendlyRequestId};
 }
Exemplo n.º 7
0
        public UpdateRequestResponse UpdateRequest(string authenticationId, string sessionId, Request request)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<ITravelServiceRest>(Configuration.TravelServiceConfigurationName);
                    ITravelServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "UpdateRequest");
                            UpdateRequestResponse response = channel.UpdateRequest(authenticationId, sessionId, request);
                            return response;
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "UpdateRequest", Severity.Major);
                }
            }
            return null;
        }