Esempio n. 1
0
        public async Task RefreshDataAsync()
        {
            var table = client.GetTable <Resources>();

            tableData = await(from a in table select a).ToListAsync();

            Items.Clear();

            foreach (var item in tableData)
            {
                MainPageItem newItem = new MainPageItem()
                {
                    Id       = item.Id,
                    Name     = item.Name,
                    Address  = item.Address,
                    Lat      = item.Lat,
                    Lon      = item.Lon,
                    Food     = Convert.ToBoolean(item.Food),
                    Medicine = Convert.ToBoolean(item.Medicine),
                    Clothes  = Convert.ToBoolean(item.Clothes),
                    Shelter  = Convert.ToBoolean(item.Shelter)
                };
                Items.Add(newItem);
            }
        }
Esempio n. 2
0
        public async Task DeleteItemAsync(MainPageItem item)
        {
            var table          = client.GetTable <Resources>();
            var resourceDelete = (await(from a in table where a.Id == item.Id select a).ToListAsync()).FirstOrDefault();

            await table.DeleteAsync(resourceDelete);

            Items.Remove(item);
        }
Esempio n. 3
0
        public async Task UpdateItemAsync(MainPageItem updateItem)
        {
            var table          = client.GetTable <Resources>();
            var resourceUpdate = (await(from a in table where a.Id == updateItem.Id select a).ToListAsync()).FirstOrDefault();


            resourceUpdate.Address  = updateItem.Address;
            resourceUpdate.Name     = updateItem.Name;
            resourceUpdate.Lat      = updateItem.Lat;
            resourceUpdate.Lon      = updateItem.Lon;
            resourceUpdate.Food     = Convert.ToInt32(updateItem.Food);
            resourceUpdate.Shelter  = Convert.ToInt32(updateItem.Shelter);
            resourceUpdate.Medicine = Convert.ToInt32(updateItem.Medicine);
            resourceUpdate.Clothes  = Convert.ToInt32(updateItem.Clothes);

            await table.UpdateAsync(resourceUpdate);
        }
Esempio n. 4
0
        public async Task AddItemAsync(MainPageItem newItem)
        {
            var table = client.GetTable <Resources>();

            var resources = new Resources()
            {
                Name     = newItem.Name,
                Address  = newItem.Address,
                Lon      = newItem.Lon,
                Lat      = newItem.Lat,
                Shelter  = Convert.ToInt32(newItem.Shelter),
                Food     = Convert.ToInt32(newItem.Food),
                Clothes  = Convert.ToInt32(newItem.Clothes),
                Medicine = Convert.ToInt32(newItem.Medicine)
            };

            await table.InsertAsync(resources);

            newItem.Id = resources.Id;
            Items.Add(newItem);
        }