Esempio n. 1
0
        public async Task <List <ReceiptClass> > searchItems(string business, string tax, string gst, string productName, double productPrice, string tag)
        {
            try
            {
                //List<ReceiptClass> templist = new List<ReceiptClass>();
                //AsyncAppData<ReceiptClass> item = kinveyClient.AppData<ReceiptClass>(tblName, typeof(ReceiptClass));
                //ReceiptClass[] itemList = await item.GetAsync();

                //templist = itemList.Where(p => p.user == kinveyClient.ClientUsers.CurrentUser).ToList();

                //return templist;
                List <ReceiptClass> templist = new List <ReceiptClass>();

                AsyncAppData <ReceiptClass> item = kinveyClient.AppData <ReceiptClass>(tblName, typeof(ReceiptClass));
                ReceiptClass[] itemList          = await item.GetAsync();

                templist = itemList.Where(p => p.user == kinveyClient.ClientUsers.CurrentUser)
                           .Where(x => string.IsNullOrEmpty(x.business) || x.business == business)
                           //.Where(x => string.IsNullOrEmpty(x.taxInvoice) || x.taxInvoice == tax)
                           //.Where(x => string.IsNullOrEmpty(x.gstNum) || x.gstNum == gst)
                           //.Where(x => string.IsNullOrEmpty(x.productName) || x.productName == productName)
                           //.Where(x => x.productTotal == 0 || x.productTotal == productPrice)
                           //.Where(x => string.IsNullOrEmpty(x.tag) || x.tag == tag)
                           .ToList();

                return(templist);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }
Esempio n. 2
0
 public static void Init()
 {
     if (kinveyStore == null)
     {
         kinveyStore = kinveyClient.AppData <TodoItem> ("todo", typeof(TodoItem));
     }
 }
Esempio n. 3
0
        public async void addItem(string business, DateTime dateAndTime, string taxInvoice,
                                  string gstNum, string serverName, string productName, double productTotal, string phone,
                                  string address, string tag, byte[] image)
        {
            try
            {
                ReceiptClass item = new ReceiptClass();

                item.user         = kinveyClient.ClientUsers.CurrentUser;
                item.business     = business;
                item.dateAndTime  = dateAndTime;
                item.taxInvoice   = taxInvoice;
                item.gstNum       = gstNum;
                item.serverName   = serverName;
                item.productName  = productName;
                item.productTotal = productTotal;
                item.phone        = phone;
                item.address      = address;
                item.tag          = tag;
                item.image        = image;

                AsyncAppData <ReceiptClass> myBook = kinveyClient.AppData <ReceiptClass>(tblName, typeof(ReceiptClass));
                ReceiptClass saved = await myBook.SaveAsync(item);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 4
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            myClient = ((AppDelegate)UIApplication.SharedApplication.Delegate).myClient;

            if (!myClient.User().isUserLoggedIn())
            {
                await myClient.User().LoginAsync();
            }


            Console.WriteLine("logged in as: " + myClient.User().Id);

            cache = new InMemoryCache <MyEntity> ();

            saveButton.TouchUpInside += async(object sender, EventArgs e) => {
                AsyncAppData <MyEntity> entityCollection = myClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));
                entityCollection.setCache(cache, CachePolicy.CACHE_FIRST);

                MyEntity ent = new MyEntity();
                ent.Email = "*****@*****.**";
                ent.Name  = "James Dean";
                ent.ID    = stableId;

                MyEntity entity = await entityCollection.SaveAsync(ent);

                Console.WriteLine("saved: " + entity.ID);
            };

            loadButton.TouchUpInside += async(object sender, EventArgs e) => {
                AsyncAppData <MyEntity> entityCollection = myClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

                MyEntity entity = await entityCollection.GetEntityAsync(stableId);

                Console.WriteLine("loaded: " + entity.ID);
            };

            queryButton.TouchUpInside += async(object sender, EventArgs e) => {
                AsyncAppData <MyEntity> entityCollection = myClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

                MyEntity[] entities = await entityCollection.GetAsync();

                Console.WriteLine("god: " + entities.Length);
            };

            loadCacheButton.TouchUpInside += async(object sender, EventArgs e) => {
                AsyncAppData <MyEntity> entityCollection = myClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

                entityCollection.setCache(cache, CachePolicy.CACHE_FIRST);

                MyEntity entity = await entityCollection.GetEntityAsync(stableId);

                Console.WriteLine("loaded: " + entity);
            };
        }
        private async void loadFromCacheAndToast()
        {
            AsyncAppData <MyEntity> entityCollection = kinveyClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

            entityCollection.setCache(myCache, CachePolicy.CACHE_FIRST);


            MyEntity entity = await entityCollection.GetEntityAsync(STABLE_ID);

            Toast.MakeText(this, "got: " + entity.Name, ToastLength.Short).Show();
        }
        private async void loadAndToast()
        {
            AsyncAppData <MyEntity> entityCollection = kinveyClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));
            //entityCollection.setOffline(new SQLiteOfflineStore(), OfflinePolicy.LOCAL_FIRST);



            MyEntity res = await entityCollection.GetEntityAsync(STABLE_ID);

            Toast.MakeText(this, "got: " + res.Name, ToastLength.Short).Show();
        }
Esempio n. 7
0
 public async void deleteItem(string editID)
 {
     try
     {
         if (editID != "")
         {
             AsyncAppData <ReceiptClass> myBook = kinveyClient.AppData <ReceiptClass>(tblName, typeof(ReceiptClass));
             await myBook.DeleteAsync(editID);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Esempio n. 8
0
        public async void editItem(string editID, ReceiptClass newList)
        {
            try
            {
                AsyncAppData <ReceiptClass> myBook = kinveyClient.AppData <ReceiptClass>(tblName, typeof(ReceiptClass));
                ReceiptClass editList = await myBook.GetEntityAsync(editID);

                editList = newList;

                ReceiptClass saved = await myBook.SaveAsync(editList);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 9
0
        public async Task <List <ReceiptClass> > getOneItem(string ID)
        {
            try
            {
                List <ReceiptClass>         templist = new List <ReceiptClass>();
                AsyncAppData <ReceiptClass> item     = kinveyClient.AppData <ReceiptClass>(tblName, typeof(ReceiptClass));
                ReceiptClass[] itemList = await item.GetAsync();

                templist = itemList.Where(p => p.user == kinveyClient.ClientUsers.CurrentUser && p.id == ID).ToList();

                return(templist);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }
Esempio n. 10
0
        private async void loadFromQuery()
        {
            AsyncAppData <MyEntity> query = kinveyClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

            //	query.setOffline (new SQLiteOfflineStore(), OfflinePolicy.LOCAL_FIRST);
            var query1 = from cust in query
                         where cust.Name == "James Dean"
                         select cust;


            Task.Run(() => {
                foreach (MyEntity e in query1)
                {
                    Console.WriteLine("got -> " + e.Name);
                }
                Console.WriteLine("total at: " + query1.Count());
            });
        }
Esempio n. 11
0
        private async void saveAndToast()
        {
            AsyncAppData <MyEntity> entityCollection = kinveyClient.AppData <MyEntity>(COLLECTION, typeof(MyEntity));

            MyEntity ent = new MyEntity();

            ent.Email = "*****@*****.**";
            ent.Name  = "James Dean";
            ent.ID    = STABLE_ID;
            //entityCollection.setOffline(new SQLiteOfflineStore(), OfflinePolicy.LOCAL_FIRST);
            try{
                MyEntity entity = await entityCollection.SaveAsync(ent);

                Toast.MakeText(this, "saved: " + entity.Name, ToastLength.Short).Show();
            }catch (Exception e) {
                Toast.MakeText(this, "something went wrong; " + e.Message, ToastLength.Short).Show();
            }
        }
        public static void saveUpdate(UpdateEntity entity, Stream bytes, KinveyDelegate <UpdateEntity> delegates)
        {
            AsyncAppData <UpdateEntity> appData = getClient().AppData <UpdateEntity> (update_collection, typeof(UpdateEntity));

            FileMetaData fm = new FileMetaData();

            fm.acl = new AccessControlList();
            fm.acl.globallyReadable = true;
            fm._public = true;

            getClient().File().upload(fm, bytes, new KinveyDelegate <FileMetaData> {
                onSuccess = (meta) => {
                    entity.attachement = new KinveyFile(meta.id);
                    appData.Save(entity, delegates);
                },
                onError = (error) => {
                }
            });
        }
        public static void getUpdates(KinveyDelegate <UpdateEntity[]> entities)
        {
            AsyncAppData <UpdateEntity> appData = getClient().AppData <UpdateEntity> (update_collection, typeof(UpdateEntity));

            appData.Get(entities);
        }