public static async Task AddAsync(string stopCode, string name)
        {
            History history = new History
            {
                StopCode  = stopCode,
                Name      = name,
                TimeStamp = DateTime.Now
            };

            await TramlineFiveContext.AddAsync(history);

            HistoryAdded?.Invoke(new HistoryDomain(history), new EventArgs());
        }
Example #2
0
        protected override async void OnStart()
        {
            IPathService dbPathService = DependencyService.Get <IPathService>();

            TramlineFiveContext.DatabasePath = dbPathService.DBPath;
            await TramlineFiveContext.EnsureCreatedAsync();

            await SimpleIoc.Default.GetInstance <HistoryViewModel>().LoadHistoryAsync();

            await SimpleIoc.Default.GetInstance <FavouritesViewModel>().LoadFavouritesAsync();

            StopsLoader.OnStopsUpdated += OnStopsUpdated;
        }
        public static async Task <FavouriteDomain> AddAsync(string name, string stopCode)
        {
            if ((await TramlineFiveContext.FindFavouriteAsync(stopCode)) != null)
            {
                return(null);
            }

            Favourite added = new Favourite
            {
                Name     = name,
                StopCode = stopCode
            };

            await TramlineFiveContext.AddAsync(added);

            return(new FavouriteDomain(added));
        }
 public static async Task CleanHistoryAsync()
 {
     await TramlineFiveContext.CleanHistoryAsync();
 }
        //public static void Remove(History history)
        //{
        //    using (TramlineFiveContext context = new TramlineFiveContext())
        //    {
        //        context.History.Remove(history);
        //        context.SaveChanges();
        //    }
        //}

        public static async Task <IEnumerable <HistoryDomain> > TakeAsync(int count = 10)
        {
            return((await TramlineFiveContext.TakeByDescending <History, DateTime>(h => h.TimeStamp, count)).Select(h => new HistoryDomain(h)));
        }
 public static async Task RemoveAsync(string stopCode)
 {
     await TramlineFiveContext.RemoveFavouriteAsync(stopCode);
 }
 public static async Task <IEnumerable <FavouriteDomain> > TakeAsync()
 {
     return((await TramlineFiveContext.TakeAll <Favourite>()).Select(f => new FavouriteDomain(f)));
 }