Exemplo n.º 1
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            CurrentPlatform.Init();

            //List to hold results of following add operations
            List <Task> results = new List <Task>();
            // Adding Users
            var users     = new UserList();
            var tableUser = AzureDataService.Client.GetTable <User>();

            users.ForEach(u =>
            {
                results.Add(
                    tableUser.InsertAsync(u)
                    );
            });

            // Adding videos
            var videos     = new VideoList();
            var tableVideo = AzureDataService.Client.GetTable <Video>();

            videos.ForEach(v =>
            {
                results.Add(
                    tableVideo.InsertAsync(v)
                    );
            });

            // Adding  units
            var units      = new UnitList();
            var tableUnits = AzureDataService.Client.GetTable <Unit>();

            units.ForEach(u =>
            {
                results.Add(
                    tableUnits.InsertAsync(u)
                    );
            });

            // Adding Units for Users. Just going to populate table with data for now. TODO: User object should contain units. Store data properly on backend
            var userUnitList  = new UserUnitList();
            var tableUnitList = AzureDataService.Client.GetTable <UserUnit>();

            userUnitList.ForEach(u =>
            {
                results.Add(
                    tableUnitList.InsertAsync(u)
                    );
            });


            RefreshUI(results);
            //ThreadPool.QueueUserWorkItem(o => DownloadVideo());
        }