public IEnumerable <Article> GetAll(ArticleIncludes includes = null)
 {
     return(_context.Articles
            .AddIncludes(includes)
            .AsEnumerable());
 }
 public Article Get(Guid id, ArticleIncludes includes = null)
 {
     return(_context.Articles
            .AddIncludes(includes)
            .FirstOrDefault(i => i.Id == id));
 }
 public IEnumerable <Article> Find(Expression <Func <Article, bool> > predicate, ArticleIncludes includes = null)
 {
     return(_context.Articles
            .AddIncludes(includes)
            .Where(predicate)
            .AsEnumerable()); //Add the where clause and return IEnumerable<Article>
 }
        /// <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 <Article> AddIncludes(this IQueryable <Article> query, ArticleIncludes includes)
        {
            if (includes == null)
            {
                return(query);
            }

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

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


            return(query);
        }
Esempio n. 5
0
 public IList <Article> GetRentedArticles(Guid customerId, ArticleIncludes includes)
 {
     return(_unitOfWork.Articles.Find(ri => ri.Status == ArticleStatus.Normal &&
                                      ri.OrderLines.Any(rol => !rol.ReturnedAt.HasValue && rol.Order.CustomerId == customerId), includes).ToList());
 }
Esempio n. 6
0
 public IList <Article> GetAvailableArticles(Guid productId, ArticleIncludes includes)
 {
     return(_unitOfWork.Articles.Find(a => a.ProductId == productId &&
                                      a.Status == ArticleStatus.Normal &&
                                      a.OrderLines.All(ol => ol.ReturnedAt.HasValue), includes).ToList());
 }
Esempio n. 7
0
 public IList <Article> All(ArticleIncludes includes)
 {
     return(_unitOfWork.Articles.GetAll(includes).ToList());
 }
Esempio n. 8
0
 public Article Get(Guid id, ArticleIncludes includes)
 {
     return(_unitOfWork.Articles.Get(id, includes));
 }