Exemple #1
0
        public async Task <AbstractItemViewModel> GetItem(string name)
        {
            var stringItemViewModelGotten = new StringItemViewModel();

            using (var db = new SQLiteConnection(DatabaseHandler.DBPath))
            {
                //StringItemModel modelGotten;

                var modelGotten = (db.Table <StringItemModel>().Where(c => c.Name == name)).SingleOrDefault();


                if (modelGotten != null)
                {
                    stringItemViewModelGotten.Name              = modelGotten.Name;
                    stringItemViewModelGotten.IsEncrypted       = modelGotten.IsEncrypted;
                    stringItemViewModelGotten.Content           = modelGotten.Content;
                    stringItemViewModelGotten.Nonce             = CryptographicBuffer.DecodeFromBase64String(modelGotten.Nonce);
                    stringItemViewModelGotten.AuthenticationTag =
                        CryptographicBuffer.DecodeFromBase64String(modelGotten.AuthenticationTag);
                }
                else
                {
                    throw new ArgumentException("No item with that ID");
                }
            }
            return(stringItemViewModelGotten);
        }
 public StringItemObservableCollection GetStringItems()
 {
     StringItems = new StringItemObservableCollection();
     using (var db = new SQLiteConnection(DatabaseHandler.DBPath))
     {
         var query = db.Table <StringItemViewModel>().OrderBy(c => c.Name);
         foreach (var stringItem in query)
         {
             var customer = new StringItemViewModel
             {
                 ID          = stringItem.ID,
                 Name        = stringItem.Name,
                 Content     = stringItem.Content,
                 IsEncrypted = stringItem.IsEncrypted
             };
             StringItems.Add(customer);
         }
     }
     return(StringItems);
 }