Exemplo n.º 1
0
        public async Task Delete(int ItemId)
        {
            using (var context = new Connection(connectionString))
            {
                Item item = context.Items.Where(i => i.ItemId == ItemId).FirstOrDefault();


                if (item != null)
                {
                    context.Entry(item).State = EntityState.Deleted;
                }
                await context.SaveChangesAsync();
            }
        }
Exemplo n.º 2
0
        public async Task Update(int itemId, Item item)
        {
            using (var context = new  Connection(connectionString))
            {
                Item OldItem = context.Items.Where(i => i.ItemId == itemId).FirstOrDefault();

                if (OldItem != null)
                {
                    OldItem.Name = item.Name;
                    context.Entry(OldItem).State = EntityState.Modified;
                }

                await context.SaveChangesAsync();
            }
        }