Ejemplo n.º 1
0
        public static string GetSalesWithAppliedDiscount(CarDealerContext context)
        {
            var sales = context
                        .Sales
                        .ProjectTo <DTOs.Export.SaleDTO>(MapperApplier.Configuration)
                        .ToArray();

            return(XmlApplier.SerializeCollection(sales, "sales"));
        }
Ejemplo n.º 2
0
        public static string GetLocalSuppliers(CarDealerContext context)
        {
            var suppliers = context
                            .Suppliers
                            .Where(x => !x.IsImporter)
                            .ProjectTo <DTOs.Export.SupplierDTO>(MapperApplier.Configuration)
                            .ToArray();

            return(XmlApplier.SerializeCollection(suppliers, "suppliers"));
        }
Ejemplo n.º 3
0
        public static string GetCarsWithTheirListOfParts(CarDealerContext context)
        {
            var cars = context
                       .Cars
                       .OrderByDescending(x => x.TravelledDistance)
                       .ThenBy(x => x.Model)
                       .ProjectTo <Task17CarDTO>(MapperApplier.Configuration)
                       .Take(5)
                       .ToArray();

            return(XmlApplier.SerializeCollection(cars, "cars"));
        }
Ejemplo n.º 4
0
        public static string GetCarsFromMakeBmw(CarDealerContext context)
        {
            var cars = context
                       .Cars
                       .Where(x => x.Make == "BMW")
                       .OrderBy(x => x.Model)
                       .ThenByDescending(x => x.TravelledDistance)
                       .ProjectTo <Task15CarDTO>(MapperApplier.Configuration)
                       .ToArray();

            return(XmlApplier.SerializeCollection(cars, "cars"));
        }
Ejemplo n.º 5
0
        public static string GetCarsWithDistance(CarDealerContext context)
        {
            var cars = context
                       .Cars
                       .Where(x => x.TravelledDistance > 2_000_000)
                       .ProjectTo <DTOs.Export.Task14CarDTO>(MapperApplier.Configuration)
                       .OrderBy(x => x.Make)
                       .ThenBy(x => x.Model)
                       .Take(10)
                       .ToArray();

            return(XmlApplier.SerializeCollection(cars, "cars"));
        }
Ejemplo n.º 6
0
        public static string GetTotalSalesByCustomer(CarDealerContext context)
        {
            var customers = context
                            .Customers
                            .Where(x => x.Sales.Count > 0)
                            .Select(x => new CustomerDTO
            {
                FullName        = x.Name,
                BoughtCarsCount = x.Sales.Count,
                SpentMoney      = x.Sales.Sum(s => s.Car.PartCars.Sum(p => p.Part.Price))
            })
                            .OrderByDescending(x => x.SpentMoney)
                            .ToArray();

            return(XmlApplier.SerializeCollection(customers, "customers"));
        }