Exemplo n.º 1
0
        public AssetHistory AddItem(AssetHistory item)
        {
            dataContext.AssetHistories.Add(item);
            dataContext.SaveChanges();

            return(item);
        }
Exemplo n.º 2
0
        public AssetHistory UpdateItem(AssetHistory item)
        {
            var existingObject = (from row in dataContext.AssetHistories
                                  where row.ID == item.ID
                                  select row).FirstOrDefault();

            if (existingObject != null)
            {
                dataContext.Entry(existingObject).CurrentValues.SetValues(item);
                dataContext.SaveChanges();
                return(item);
            }

            else
            {
                throw new InvalidOperationException("Entry could not be found.");
            }
        }