Example #1
0
        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);
        }
Example #2
0
        public static async Task <T> UpdateAsync <T>(this LuciferContext context, T entity) where T : EntityBase
        {
            context.Upsert(entity);

            await context.SaveChangesAsync();

            return(entity);
        }
Example #3
0
        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);
        }