Exemplo n.º 1
0
        public static string GetCategoriesByProductsCount(ProductShopContext context)
        {
            var categories = context
                             .Categories
                             .ProjectTo <Task7CategoryDTO>(MapperApplier.MapperConfiguration)
                             .OrderByDescending(x => x.Count)
                             .ThenBy(x => x.TotalRevenue)
                             .ToArray();

            return(XmlApplier.SerializeMany("Categories", categories));
        }
Exemplo n.º 2
0
        public static string GetProductsInRange(ProductShopContext context)
        {
            var products = context
                           .Products
                           .Where(x => x.Price >= 500 && x.Price <= 1000)
                           .ProjectTo <Task5ProductDTO>(MapperApplier.MapperConfiguration)
                           .OrderBy(x => x.Price)
                           .Take(10)
                           .ToArray();

            return(XmlApplier.SerializeMany("Products", products));
        }
Exemplo n.º 3
0
        public static string GetSoldProducts(ProductShopContext context)
        {
            var users = context
                        .Users
                        .Where(x => x.ProductsSold.Any(x => x.Buyer != null))
                        .ProjectTo <Task6UserDTO>(MapperApplier.MapperConfiguration)
                        .OrderBy(x => x.LastName)
                        .ThenBy(x => x.FirstName)
                        .Take(5)
                        .ToArray();

            return(XmlApplier.SerializeMany("Users", users));
        }