Beispiel #1
0
        public async Task <bool> RemoveItem(int id)
        {
            using (var db = new LoetopiaContext())
            {
                var entity = db.Items.Where(x => x.ItemId == id).FirstOrDefault();
                entity.Active = false;

                db.Entry(entity).State = EntityState.Modified;

                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #2
0
        public async Task <bool> UpdateItem(int id, Item item)
        {
            using (var db = new LoetopiaContext())
            {
                if (id != item.ItemId)
                {
                    return(false);
                }

                db.Entry(item).State = EntityState.Modified;

                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }