public virtual async Task <T> UpdateAsync(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            //item.Datestamp = DateTime.Now;
            //_dbContext.Set(item.GetType()).Attach(item);

            _dbContext.Entry(item).State = EntityState.Modified;
            if (UpdatingRecord != null)
            {
                UpdatingRecord.Invoke(this, new EntitySavingEventArgs <T>()
                {
                    SavedEntity = item
                });
            }

            await _dbContext.SaveChangesAsync();

            if (RecordUpdated != null)
            {
                RecordUpdated.Invoke(this, new EntitySavingEventArgs <T>()
                {
                    SavedEntity = item
                });
            }

            return(item);
        }
Exemple #2
0
        public virtual void Update(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _dbContext.Entry(item).State = EntityState.Modified;
            if (UpdatingRecord != null)
            {
                UpdatingRecord.Invoke(this, new EntitySavingEventArgs <T>()
                {
                    SavedEntity = item
                });
            }

            _dbContext.SaveChanges();
            if (RecordUpdated != null)
            {
                RecordUpdated.Invoke(this, new EntitySavingEventArgs <T>()
                {
                    SavedEntity = item
                });
            }
        }