public static async Task AddItemCategory(this AppDbContext db, ItemCategory itemCategory) { if (await itemCategory.Validate(db)) { db.ItemCategories.Attach(itemCategory); await db.SaveChangesAsync(); } }
public static async Task UpdateItemCategory(this AppDbContext db, ItemCategory itemCategory) { if (await itemCategory.Validate(db)) { var i = await db.ItemCategories.FindAsync(itemCategory.Id); i.Label = itemCategory.Label; await db.SaveChangesAsync(); } }