public IEnumerable <ProductResult> GetAllResult(ProductIncludes includes = null)
 {
     return(_context.Products
            .AddIncludes(includes)
            .MapToResults()
            .AsEnumerable());
 }
        /// <summary>
        /// Adds the DbContext includes based on the booleans set in the Includes object
        /// </summary>
        /// <param name="query"></param>
        /// <param name="includes"></param>
        /// <returns></returns>
        public static IQueryable <Product> AddIncludes(this IQueryable <Product> query, ProductIncludes includes)
        {
            if (includes == null)
            {
                return(query);
            }

            if (includes.Articles)
            {
                query = query.Include(i => i.Articles);
            }

            if (includes.ArticleOrderLines)
            {
                query = query
                        .Include(p => p.Articles)
                        .ThenInclude(a => a.OrderLines);
            }

            return(query);
        }
 public IList <ProductResult> AllResult(ProductIncludes includes)
 {
     return(_unitOfWork.Products.GetAllResult(includes).ToList());
 }
 public Product Get(Guid id, ProductIncludes includes)
 {
     return(_unitOfWork.Products.Get(id, includes));
 }
 public IEnumerable <ProductResult> FindResult(Expression <Func <Product, bool> > predicate, ProductIncludes includes = null)
 {
     return(_context.Products
            .AddIncludes(includes)
            .Where(predicate)
            .MapToResults()
            .AsEnumerable());
 }
 public IEnumerable <Product> GetAll(ProductIncludes includes = null)
 {
     return(_context.Products
            .AddIncludes(includes)
            .AsEnumerable());
 }
 public Product Get(Guid id, ProductIncludes includes = null)
 {
     return(_context.Products
            .AddIncludes(includes)
            .FirstOrDefault(i => i.Id == id));
 }