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); } }
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); } }