示例#1
0
        public virtual T Update(T item)
        {
            if (_updateableBiggyStore != null)
            {
                _updateableBiggyStore.Update(item);
                _luceneIndexer.UpdateDocumentInIndex(item);
            }

            return(item);
        }
示例#2
0
 public virtual T Update(T item)
 {
     if (_updateableBiggyStore != null)
     {
         _updateableBiggyStore.Update(item);
     }
     else
     {
         _store.SaveAll(_items);
     }
     Fire(Changed, item: item);
     return(item);
 }
示例#3
0
        public void Updates_Item_In_Store()
        {
            _widgets.Clear();
            _widgets.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });
            var updateMe = _widgets.Load().FirstOrDefault();

            updateMe.Name = "UPDATED";
            _updateableWidgets.Update(updateMe);

            var updated = _widgets.Load().FirstOrDefault();

            Assert.True(updated.Name == "UPDATED");
        }
示例#4
0
        public void IUpdateableBiggyStore_Updates_Record()
        {
            _updateableStore = new SqlCeStore <Client>(_connectionStringName) as IUpdateableBiggyStore <Client>;
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _updateableStore.Add(newClient);

            // Stow the id so we can reload, then update (just to be SURE!!)
            int idToFind = newClient.ClientId;

            newClient           = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
            newClient.FirstName = "John Paul";
            newClient.LastName  = "Jones";
            _updateableStore.Update(newClient);

            var updatedClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            Assert.True(updatedClient.LastName == "Jones");
        }
示例#5
0
        public virtual T Update(T item)
        {
            T itemFromList = default(T);

            if (!_items.Contains(item))
            {
                // Figure out what to do here. Retreive Key From Store and evaluate?
                throw new InvalidOperationException(
                          @"The list does not contain a reference to the object passed as an argument. 
          Make sure you are passing a valid reference, or override Equals on the type being passed.");
            }
            else
            {
                itemFromList = _items.ElementAt(_items.IndexOf(item));
                if (!ReferenceEquals(itemFromList, item))
                {
                    //// The items are "equal" but do not refer to the same instance.
                    //// Somebody overrode Equals on the type passed as an argument. Replace:
                    int index = _items.IndexOf(item);
                    _items.RemoveAt(index);
                    _items.Insert(index, item);
                }
                // From here forward, the item passed in refers to the item in the list.
            }
            if (_store != null && !this.InMemory)
            {
                if (_updateableStore != null && !this.InMemory)
                {
                    _updateableStore.Update(item);
                }
                else
                {
                    _store.SaveAll(_items);
                }
            }
            Fire(Changed, item: item);
            return(item);
        }
示例#6
0
        public void IUpdateableBiggyStore_Updates_Record()
        {
            _updateableStore = new PGStore<Client>(_connectionStringName) as IUpdateableBiggyStore<Client>;
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _updateableStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              newClient.FirstName = "John Paul";
              newClient.LastName = "Jones";
              _updateableStore.Update(newClient);

              var updatedClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              Assert.True(updatedClient.LastName == "Jones");
        }