예제 #1
0
        public IHttpActionResult GetOrderOnlineList(string airport_code, int?skip, int?take)
        {
            if (string.IsNullOrWhiteSpace(airport_code))
            {
                throw new ArgumentException("message", nameof(airport_code));
            }

            ReturnObject <List <OrderSession> > ret = new ReturnObject <List <OrderSession> >();

            try
            {
                var omSrv = new OrderService(omDB);
                ret.Data = omSrv.GetOrderOnlineList(airport_code, skip, take);

                ret.totalCount  = ret.Data.Count;
                ret.isCompleted = true;
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret));
        }
예제 #2
0
        public IHttpActionResult CancelOrderOnline(string order_no)
        {
            if (string.IsNullOrWhiteSpace(order_no))
            {
                throw new ArgumentException("message", nameof(order_no));
            }

            ReturnObject <OrderSession> ret = new ReturnObject <OrderSession>();

            try
            {
                var omSrv   = new OrderService(omDB);
                var posConn = omSrv.GetConnectionPOSOrder(order_no);
                if (posConn != null)
                {
                    posDB    = new POSAirPortClassesDataContext(posConn);
                    ret.Data = omSrv.CancelOrderOnline(posDB, order_no);

                    ret.totalCount  = ret.Data != null ? 1 : 0;
                    ret.isCompleted = true;
                }
                else
                {
                    throw new ArgumentException("message", "connection error");
                }
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }


            return(Ok(ret));
        }
예제 #3
0
        public IHttpActionResult GetOrderOnline(string order_no)
        {
            if (string.IsNullOrWhiteSpace(order_no))
            {
                throw new ArgumentException("message", nameof(order_no));
            }

            ReturnObject <OrderSession> ret = new ReturnObject <OrderSession>();

            try
            {
                var omSrv = new OrderService(omDB);
                ret.Data        = omSrv.GetOrderOnline(order_no);
                ret.totalCount  = ret.Data != null? 1 : 0;
                ret.isCompleted = true;
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }


            return(Ok(ret));
        }
예제 #4
0
        public IHttpActionResult SaveOrderOnline(OrderHeader order)
        {
            // validate data
            /////

            ReturnObject <OrderSession> ret = new ReturnObject <OrderSession>();

            try
            {
                var omSrv   = new OrderService(omDB);
                var posConn = omSrv.GetConnectionPOSAirport(order.Flight.AirportCode);
                if (posConn != null)
                {
                    posDB    = new POSAirPortClassesDataContext(posConn);
                    ret.Data = omSrv.SaveOrderOnline(posDB, order);

                    ret.totalCount  = ret.Data != null ? 1 : 0;
                    ret.isCompleted = true;
                }
                else
                {
                    throw new ArgumentException("message", "connection error");
                }
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret));
        }
예제 #5
0
        public IHttpActionResult CheckFlights(string flight_code, string flight_date)
        {
            ReturnObject <Flight> ret = new ReturnObject <Flight>();

            try
            {
                if (string.IsNullOrEmpty(flight_code))
                {
                    throw new ArgumentException("flight code", nameof(flight_code));
                }

                if (string.IsNullOrEmpty(flight_date))
                {
                    throw new ArgumentException("flight date", nameof(flight_date));
                }


                var srv = new FlightService(orderDB);
                ret.Data        = srv.CheckFlights(flight_code, flight_date);
                ret.totalCount  = 1;
                ret.isCompleted = true;
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }


            return(Ok(ret));
        }
예제 #6
0
        public IHttpActionResult GetAll()
        {
            ReturnObject <FlightsAll> ret = new ReturnObject <FlightsAll>();

            try
            {
                var srv = new FlightService(orderDB);
                ret.Data = srv.GetDataAll();

                int d = ret.Data.Departure.Count;
                int a = ret.Data.Arrival.Count;
                int z = ret.Data.Transfer.Count;

                ret.totalCount  = d + a + z;
                ret.isCompleted = true;
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                //ret.Tracking = new ReturnTracking();
            }


            return(Ok(ret));
        }
예제 #7
0
        public IHttpActionResult CheckAllowSaleOnline(string airport_code, string flight_code, string flight_date, string passport)
        {
            ReturnObject <SaleAmountByPassport> ret = new ReturnObject <SaleAmountByPassport>();

            try
            {
                if (string.IsNullOrEmpty(airport_code))
                {
                    throw new ArgumentException("message", nameof(airport_code));
                }

                if (string.IsNullOrEmpty(flight_code))
                {
                    throw new ArgumentException("message", nameof(flight_code));
                }

                if (string.IsNullOrEmpty(passport))
                {
                    throw new ArgumentException("message", nameof(passport));
                }

                DateTime flight_datetime = Convert.ToDateTime(flight_date);
                if (string.IsNullOrEmpty(flight_date))
                {
                    throw new ArgumentException("message", nameof(flight_date));
                }
                else
                {
                    CultureInfo provider = CultureInfo.InvariantCulture;
                    flight_datetime = DateTime.ParseExact(flight_date, "yyyy-MM-dd", provider);
                }

                var omSrv   = new OrderService(omDB);
                var posConn = omSrv.GetConnectionPOSAirport(airport_code);
                if (posConn != null)
                {
                    posDB    = new POSAirPortClassesDataContext(posConn);
                    ret.Data = omSrv.ValidateAllowSaleOnline(posDB, passport, flight_datetime, flight_code);
                    //ret.Data = new SaleAmountByPassport();
                    ret.Data.SaleAmt = ret.Data.SaleAmt;
                    ret.Data.Alcohol = ret.Data.Alcohol;
                    ret.Data.Tobacco = ret.Data.Tobacco;
                    ret.totalCount   = ret.Data != null ? 1 : 0;
                    ret.isCompleted  = true;
                }
                else
                {
                    throw new ArgumentException("message", "connection error");
                }
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret));
        }
예제 #8
0
        public IHttpActionResult GetTransfer()
        {
            ReturnObject <List <Flight> > ret = new ReturnObject <List <Flight> >();

            try
            {
                var srv = new FlightService(orderDB);
                ret.Data        = srv.GetDataTransfer();
                ret.totalCount  = ret.Data.Count;
                ret.isCompleted = true;
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret));
        }
        public IHttpActionResult SaleQueueOnline(string airport_code, char terminal)
        {
            ReturnObject <List <SaleQueue> > ret = new ReturnObject <List <SaleQueue> >();

            try
            {
                if (string.IsNullOrWhiteSpace(airport_code))
                {
                    throw new ArgumentException("message", nameof(airport_code));
                }

                if (char.IsWhiteSpace(terminal))
                {
                    throw new ArgumentException("message", nameof(terminal));
                }

                var omSrv   = new OrderService(orderDB);
                var posConn = omSrv.GetConnectionPOSAirport(airport_code);
                if (posConn != null)
                {
                    var posDB = new POSAirPortClassesDataContext(posConn);
                    ret.Data        = omSrv.SaleQueue(posDB, terminal);
                    ret.totalCount  = ret.Data.Count();
                    ret.isCompleted = true;
                }
                else
                {
                    throw new ArgumentException("message", "connection error");
                }
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret.Data));
        }
예제 #10
0
        public async Task <IHttpActionResult> VoidOrderOnlineAsync(string order_no)
        {
            if (string.IsNullOrWhiteSpace(order_no))
            {
                throw new ArgumentException("message", nameof(order_no));
            }

            ReturnObject <OrderSession> ret = new ReturnObject <OrderSession>();

            try
            {
                var omSrv   = new OrderService(omDB);
                var posConn = omSrv.GetConnectionPOSOrder(order_no);
                if (posConn != null)
                {
                    posDB    = new POSAirPortClassesDataContext(posConn);
                    ret.Data = omSrv.VoidOrderOnline(posDB, order_no);
                    if (ret.Data != null)
                    {
                        // send update to endpoint CANCELED
                        var client  = new RestClient("http://10.3.26.32:5000");
                        var request = new RestRequest(String.Format("dev/api/Orders/{0}/Status", order_no), Method.POST);
                        request.AddHeader("AccessToken", "A64803F0A7CEDAC8407538D341BDBE23");
                        request.AddHeader("Content-Type", "application/json");
                        request.AddJsonBody(new { statuscode = "refund" });
                        var restResponse = await client.ExecutePostTaskAsync(request);

                        if (restResponse.ErrorException != null)
                        {
                            throw restResponse.ErrorException.InnerException;
                        }
                        else
                        {
                            if (restResponse.StatusCode != HttpStatusCode.OK)
                            {
                                ret.Data        = omSrv.UpdateStatusOrderOnline(order_no, restResponse.StatusCode.ToString());
                                ret.totalCount  = 0;
                                ret.isCompleted = false;
                            }
                            else
                            {
                                ret.Data        = omSrv.UpdateStatusOrderOnline(order_no, "refund");
                                ret.totalCount  = 1;
                                ret.isCompleted = true;
                            }
                        }
                    }
                    else
                    {
                        throw new ArgumentException("message", "connection error");
                    }
                }
                else
                {
                    throw new ArgumentException("message", "connection error");
                }
            }
            catch (Exception e)
            {
                ret.SetMessage(e);
                ret.Tracking = new ReturnTracking();
            }

            return(Ok(ret));
        }