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)); }
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)); }
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)); }