Beispiel #1
0
        public IList <Product> GetAll()
        {
            var entities = _productCollection
                           .SetupBaseQuery <IProductCollection>()
                           .OrderByName()
                           .RunQuery();

            //You should use Automapper for this
            return(entities.Select(x => new Product {
                Id = x.Id, Name = x.Name, Description = x.Description, Image = x.Image, Price = x.Price
            }).ToList());
        }
Beispiel #2
0
        private ProductEntity GetProduct(Guid itemId)
        {
            var entity = _productCollection.SetupBaseQuery <IProductCollection>().GetById(itemId).RunQuery().FirstOrDefault();

            if (entity == null)
            {
                throw new Exception("Unable to find item.");
            }

            return(entity);
        }