Car Dealer - svetlilaloli/EntityFramework-SoftUni GitHub Wiki
A car dealer needs information about cars, their parts, parts suppliers, customers, and sales.
- Cars have make, model, traveled distance in kilometers
- Parts have name, price, and quantity
- Part supplier have name and info whether he uses imported parts
- Customer has name, date of birth, and info whether he/she is a young driver (Young driver is a driver that has less than 2 years of experience. Those customers get additional 5% off for the sale.)
- Sale has a car, customer, and discount percentage
A price of a car is formed by the total price of its parts.
- A car has many parts and one part can be placed in many cars
- One supplier can supply many parts and each part can be delivered by only one supplier
- In one sale, only one car can be sold
- Each sale has one customer and a customer can buy many cars
Import data from the provided files (suppliers.json, parts.json, cars.json, customers.json, sales.json)
NOTE: You will need a method public static string ImportSuppliers(CarDealerContext context, string inputJson)
and public StartUp
class.
Import the suppliers from the provided file suppliers.json
.
Your method should return string with a message $"Successfully imported {Suppliers.Count}.";
NOTE: You will need a method public static string ImportParts(CarDealerContext context, string inputJson)
and public StartUp
class.
Import the parts from the provided file parts.json
. If the supplierId
doesnβt exist, skip the record.
Your method should return string with a message $"Successfully imported {Parts.Count}.";
NOTE: You will need a method public static string ImportCars(CarDealerContext context, string inputJson)
and public StartUp
class.
Import the cars from the provided file cars.json
.
Your method should return string with a message $"Successfully imported {Cars.Count}.";
NOTE: You will need a method public static string ImportCustomers(CarDealerContext context, string inputJson)
and public StartUp
class.
Import the customers from the provided file customers.json
.
Your method should return string with a message $"Successfully imported {Customers.Count}.";
NOTE: You will need a method public static string ImportSales(CarDealerContext context, string inputJson)
and public StartUp
class.
Import the sales from the provided file sales.json
.
Your method should return string with a message $"Successfully imported {Sales.Count}.";
Write the below-described queries and export the returned data to the specified format. Make sure that Entity Framework generates only a single query for each task.
NOTE: You will need a method public static string GetOrderedCustomers(CarDealerContext context)
and public StartUp
class.
Get all customers ordered by their birth date ascending. If two customers are born on the same date first print those who are not young drivers (e.g. print experienced drivers first). Export the list of customers to JSON in the format provided below.
ordered-customers.json |
---|
[ β{ ββ"Name": "Louann Holzworth", ββ"BirthDate": " 01/10/1960", ββ"IsYoungDriver": false β}, β{ ββ"Name": "Donnetta Soliz", ββ"BirthDate": "01/10/1963", ββ"IsYoungDriver": true β}, β... ] |
NOTE: You will need a method public static string GetCarsFromMakeToyota(CarDealerContext context)
and public StartUp
class.
Get all cars from make Toyota and order them by model alphabetically and by traveled distance descending. Export the list of cars to JSON in the format provided below.
toyota-cars.json |
---|
[ β{ ββ"Id": 134, ββ"Make": "Toyota", ββ"Model": "Camry Hybrid", ββ"TravelledDistance": 486872832, β}, β{ ββ"Id": 139, ββ"Make": "Toyota", ββ"Model": "Camry Hybrid", ββ"TravelledDistance": 397831570, β}, β... ] |
NOTE: You will need a method public static string GetLocalSuppliers(CarDealerContext context)
and public StartUp
class.
Get all suppliers that do not import parts from abroad. Get their id, name, and the number of parts they can offer to supply. Export the list of suppliers to JSON in the format provided below.
local-suppliers.json |
---|
[ β{ ββ"Id": 2, ββ"Name": "Agway Inc.", ββ"PartsCount": 3 β}, β{ ββ"Id": 4, ββ"Name": "Airgas, Inc.", ββ"PartsCount": 2w β}, β... ] |
NOTE: You will need a method public static string GetCarsWithTheirListOfParts(CarDealerContext context)
and public StartUp
class.
Get all cars along with their list of parts. For the car get only make, model, and traveled distance and for the parts get only name and price (formatted to 2nd digit after the decimal point). Export the list of cars and their parts to JSON in the format provided below.
cars-and-parts.json |
---|
[ β{ ββ"car": { βββ"Make": "Opel", βββ"Model": "Omega", βββ"TravelledDistance": 176664996 ββ}, ββ"parts": [] β}, β{ ββ"car": { βββ"Make": "Opel", βββ"Model": "Astra", βββ"TravelledDistance": 516628215 ββ}, ββ"parts": [] β}, β{ ββ"car": { βββ"Make": "Opel", βββ"Model": "Astra", βββ"TravelledDistance": 156191509 ββ}, ββ"parts": [] β}, β{ ββ"car": { βββ"Make": "Opel", βββ"Model": "Corsa", βββ"TravelledDistance": 347259126 ββ}, ββ"parts": [ βββ{ ββββ"Name": "Pillar", ββββ"Price": "100.99" βββ}, βββ{ ββββ"Name": "Valance", ββββ"Price": "1002.99" βββ}, βββ{ ββββ"Name": "Front clip", ββββ"Price": "100.00" βββ} ββ] β},... ] |
NOTE: You will need a method public static string GetTotalSalesByCustomer(CarDealerContext context)
and public StartUp
class.
Get all customers that have bought at least 1 car and get their names, bought cars count, and total spent money on cars. Order the result list by total spent money descending then by total bought cars again in descending order. Export the list of customers to JSON in the format provided below.
customers-total-sales.json |
---|
[ β{ ββ"fullName": " Johnette Derryberry", ββ"boughtCars": 5, ββ"spentMoney": 13529.25 β}, β{ ββ"fullName": " Zada Attwood", ββ"boughtCars": 6, ββ"spentMoney": 13474.31 β}, β{ ββ"fullName": " Donnetta Soliz", ββ"boughtCars": 3, ββ"spentMoney": 8922.22 β}, β... ] |
NOTE: You will need a method public static string GetSalesWithAppliedDiscount(CarDealerContext context)
and public StartUp
class.
Get first 10 sales with information about the car, customer, and price of the sale with and without discount. Export the list of sales to JSON in the format provided below.
sales-discounts.json |
---|
[ β{ ββ"car": { βββ"Make": "Seat", βββ"Model": "Mii", βββ"TravelledDistance": 473519569 ββ}, ββ"customerName": "Ann Mcenaney", ββ"Discount": "30.00", ββ"price": "2176.37", ββ"priceWithDiscount": "1523.46" β}, β{ ββ"car": { βββ"Make": "Renault", βββ"Model": "Alaskan", βββ"TravelledDistance": 303853081 ββ}, ββ"customerName": "Taina Achenbach", ββ"Discount": "10.00", ββ"price": "808.76", ββ"priceWithDiscount": "727.88" β}, β... ] |