예제 #1
0
        private async void PlanFound(MessageTypes.PlanFoundMessage _)
        {
            if (!BootStrapper.Current.SessionState.ContainsKey(NavParamKeys.PlanResults))
            {
                return;
            }

            var foundPlan = BootStrapper.Current.SessionState[NavParamKeys.PlanResults] as TripPlan;

            BootStrapper.Current.SessionState.Remove(NavParamKeys.PlanResults);
            if (foundPlan?.PlanItineraries == null)
            {
                return;
            }
            TripResults.Clear();
            FromName = foundPlan.StartingPlaceName ?? AppResources.TripPlanStrip_StartingPlaceDefault;
            ToName   = foundPlan.EndingPlaceName ?? AppResources.TripPlanStrip_EndPlaceDefault;

            //----todo: leaking abstraction here, see if we can move this to the view
            // Give the control enough time to animate back from the DetailedState,
            // so that when the TripPlanStrip does it's second render pass, it gets accurate values.
            if (IsInDetailedState)
            {
                GoBackToTripList();
                await Task.Delay(450);
            }
            //----end todo
            foreach (TripItinerary itinerary in foundPlan.PlanItineraries)
            {
                TripResults.Add(itinerary);
            }
        }
예제 #2
0
        public async Task <List <String> > GetBusClass()
        {
            try
            {
                TripResults datalist = await database.GetTripAsync();

                List <TripWithImage> datawithimage = null;

                if (datalist != null &&
                    datalist.results != null)
                {
                    datawithimage = datalist.ConvertWithImage();

                    return((from TripWithImage x in datawithimage
                            group x by x.BusClass into y
                            orderby y.Key ascending
                            select y.Key).ToList());
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        /// <summary>
        /// Get all list of trips, doing  descend order and get total order.
        /// </summary>
        /// <param name="amount">Take total</param>
        /// <returns></returns>
        public async Task <List <TripWithImage> > GetStart(int amount)
        {
            try
            {
                TripResults datalist = await database.GetTripAsync();

                List <TripWithImage> datawithimage = null;

                if (datalist != null &&
                    datalist.results != null)
                {
                    datawithimage = datalist.ConvertWithImage();

                    return((from TripWithImage x in datawithimage
                            orderby x.Price descending
                            select x).Take(amount).ToList());
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        /// <summary>
        /// Function extensions to convert
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static List <TripWithImage> ConvertWithImage(this TripResults data)
        {
            List <TripWithImage> data_result = new List <TripWithImage>();

            if (data != null &&
                data.results != null)
            {
                foreach (var item in data.results)
                {
                    TripWithImage data_value = new TripWithImage()
                    {
                        objectId      = item.objectId,
                        Company       = item.Company,
                        Origin        = item.Origin,
                        Destination   = item.Destination,
                        DepartureDate = item.DepartureDate,
                        createdAt     = item.createdAt,
                        updatedAt     = item.updatedAt,
                        Price         = item.Price,
                        BusClass      = item.BusClass,
                        ArrivalDate   = item.ArrivalDate,
                    };


                    if (data_value.Company != null)
                    {
                        if (data_value.Company.Name.Equals("Cometa", StringComparison.CurrentCultureIgnoreCase))
                        {
                            data_value.ImageSrc = "Image/Comapany/cometa.png";
                        }
                        else if (data_value.Company.Name.Equals("1001", StringComparison.CurrentCultureIgnoreCase))
                        {
                            data_value.ImageSrc = "Image/Comapany/1001.png";
                        }
                        else if (data_value.Company.Name.Equals("catarinense", StringComparison.CurrentCultureIgnoreCase))
                        {
                            data_value.ImageSrc = "Image/Comapany/catarinense.png";
                        }
                    }

                    data_result.Add(data_value);
                }

                return(data_result);
            }

            return(null);
        }
예제 #5
0
        /// <summary>
        /// Get all list of trips, doing  descend order and get total order.
        /// </summary>
        /// <param name="amount">Take total</param>
        /// <returns></returns>
        public async Task <List <TripWithImage> > GetStart(string date, string classbuss, string money)
        {
            try
            {
                TripResults datalist = await database.GetTripAsync();

                List <TripWithImage> datawithimage = null;

                if (datalist != null &&
                    datalist.results != null)
                {
                    datawithimage = datalist.ConvertWithImage();


                    DateTime datevalue;
                    if (!DateTime.TryParseExact(date, "yyyy-MM-dd",
                                                CultureInfo.InvariantCulture,
                                                DateTimeStyles.None,
                                                out datevalue))
                    {
                        datevalue = DateTime.Now;
                    }

                    double moneyvalue;
                    if (!double.TryParse(money, out moneyvalue))
                    {
                        moneyvalue = 0;
                    }


                    return((from TripWithImage x in datawithimage
                            where x.BusClass.Equals(classbuss, StringComparison.CurrentCultureIgnoreCase)
                            orderby x.Price descending
                            select x).ToList());
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public override async Task OnNavigatedFromAsync(IDictionary <string, object> suspensionState, bool suspending)
        {
            if (suspending)
            {
                IStorageFile tripResultCacheFile = await _fileService.GetTempFileAsync(
                    SuspensionKeys.TripResults_HasSavedState, CreationCollisionOption.ReplaceExisting);

                using (Stream fileStream = await tripResultCacheFile.OpenStreamForWriteAsync())
                    using (GZipStream jsonStream = new GZipStream(fileStream, CompressionLevel.Fastest))
                    {
                        jsonStream.SerializeJsonToStream(TripResults.ToArray());
                    }

                //and make a note of it in the suspension dict:
                suspensionState.AddOrUpdate(SuspensionKeys.TripResults_HasSavedState, true);
                suspensionState.AddOrUpdate(SuspensionKeys.TripResults_FromName, FromName);
                suspensionState.AddOrUpdate(SuspensionKeys.TripResults_ToName, ToName);
            }
            else //Don't want to unhook the "back-returns from Detailed View" behavior if the user is just switching apps.
            {
                BootStrapper.BackRequested -= BootStrapper_BackRequested;
            }
            await Task.CompletedTask;
        }