public static async Task <T> CreateAsync <T>(this LuciferContext context, T entity) where T : EntityBase { var created = context.Attach(entity); await context.SaveChangesAsync(); return(created.Entity); }
public static async Task <T> UpdateAsync <T>(this LuciferContext context, T entity) where T : EntityBase { context.Upsert(entity); await context.SaveChangesAsync(); return(entity); }
protected virtual async Task TrackProductsToBeDelete(LuciferContext lucifer, Model.Product product) { var descriptions = await lucifer .AttributeDescriptions .AsNoTracking() .Where(description => description.ProductId == product.Id) .ToListAsync(); var toBeDeleted = descriptions.Except(product.Descriptions); lucifer.AttributeDescriptions.RemoveRange(toBeDeleted); }