Пример #1
0
        /// <summary>
        /// Add a route to the database
        /// </summary>
        /// <parameter name="routeInfo"></parameter>
        /// <exception cref="RouteManagerException">Thrown when unable to add a route</exception>
        /// <returns>Returns the status of the insertion</returns>
        public bool AddRoute(Route routeInfo)
        {
            bool isRouteValid = false;

            isRouteValid = ValidateRouteInfo(routeInfo);
            if (isRouteValid)
            {
                try
                {
                    int noOfRows = routeDAO.AddRoute(routeInfo);
                    if (noOfRows > 0)
                    {
                        isRouteValid = true;
                    }
                }
                catch (RouteDAOException ex)
                {
                    //CSPRCR17.4 - Log an exception using the LogManager
                    LogMessage message = new LogMessage();
                    message.ClassName       = "RouteManager";
                    message.Message         = ex.Message;
                    message.MessageDateTime = DateTime.Now;
                    message.MethodName      = "AddRoute()";
                    message.ExceptionType   = "RouteDAOException";

                    Logs.LogManager manager = new Logs.LogManager(Loggers.XML);
                    manager.WriteToLog(message);

                    throw new RouteManagerException("Unable to add route", ex);
                }
            }

            return(isRouteValid);
        }
Пример #2
0
        /// <summary>
        /// Processes the payment for a given card and returns the reference no for the
        /// payment processed
        /// </summary>
        /// <param name="cardForBooking"></param>
        /// <param name="amount"></param>
        /// <param name="status"></param>
        /// <returns>Returns the payment reference number</returns>
        private string MakePayment(Card cardForBooking, decimal amount, out PaymentStatus status)
        {
            string referenceNo = string.Empty;

            //Call the Payment Service which will internally call the wcf service payment gateway
            try
            {
                //Enable when we need to deploy
                //referenceNo = paymentManager.MakePayment(cardForBooking, amount, out status);

                //Local Implementation - Comment in real time env
                referenceNo = Guid.NewGuid().ToString();
                status      = PaymentStatus.Success;
            }
            catch (PaymentNotProcessedFromServiceException ex)
            {
                //CSPRCR17.2 - Log an exception using the LogManager
                LogMessage message = new LogMessage();
                message.ClassName       = "BookingManager";
                message.Message         = ex.Message;
                message.MessageDateTime = DateTime.Now;
                message.MethodName      = "MakePayment()";
                message.ExceptionType   = "PaymentNotProcessedFromServiceException";

                Logs.LogManager manager = new Logs.LogManager(Loggers.Email);
                manager.WriteToLog(message);

                throw new PaymentProcessException("Unable to Process Payment", ex);
            }
            catch (Exception ex)
            {
                throw new PaymentProcessException("Unable to Process Payment", ex);
            }



            return(referenceNo);
        }
Пример #3
0
        /// <summary>
        /// Gets the search result for the search criteria
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws the exception when flights are not available for the given search information</exception>
        /// <returns>Returns the search result for the given search information</returns>
        private SearchResult GetSearchResult(SearchInfo searchInformation, SearchResult result)
        {
            try
            {
                //Get the Schedules from the database based on the search information
                Schedules scheduleCollection = searchDAO.SearchForFlight(searchInformation);
                if (scheduleCollection == null)
                {
                    //CSPRCR17.1 - Log an exception using the LogManager
                    LogMessage message = new LogMessage();
                    message.ClassName       = "SearchManager";
                    message.Message         = "Flights not available";
                    message.MessageDateTime = DateTime.Now;
                    message.MethodName      = "GetSearchResult()";
                    message.ExceptionType   = "FlightsNotAvailableException";

                    Logs.LogManager manager = new Logs.LogManager(Loggers.Event);
                    manager.WriteToLog(message);
                    throw new FlightsNotAvailableException("Flights not available");
                }
                //Add search result for direct flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForDirectFlights(searchInformation, scheduleCollection, result);
                }
                catch (DirectFlightsNotAvailableException)
                {
                }

                //Add search result for connecting flights from the schedules obtained from database
                //based on the search criteria
                try
                {
                    AddSearchResultForConnectingFlights(searchInformation, scheduleCollection, result);
                }
                catch (ConnectingFlightsNotAvailableException)
                {
                    //CSPRCR17.3 - Log an exception using the LogManager
                    LogMessage message = new LogMessage();
                    message.ClassName       = "SearchManager";
                    message.Message         = "Connecting Flights not available";
                    message.MessageDateTime = DateTime.Now;
                    message.MethodName      = "GetSearchResult()";
                    message.ExceptionType   = "ConnectingFlightsNotAvailableException";

                    Logs.LogManager manager = new Logs.LogManager(Loggers.File);
                    manager.WriteToLog(message);
                }
            }
            catch (SearchFlightDAOException ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }


            return(result);
        }