Skip to content

Commit a753252

Browse files
committed
EXAM PREP 10 DECEMBER 2017
1 parent 607b292 commit a753252

37 files changed

+2021
-0
lines changed
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Automapper" Version="6.2.1" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\FastFood.DataProcessor\FastFood.DataProcessor.csproj" />
14+
<ProjectReference Include="..\FastFood.Data\FastFood.Data.csproj" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<Folder Include="ImportResults\" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace FastFood.App
2+
{
3+
using AutoMapper;
4+
using FastFood.DataProcessor.Dto.Import;
5+
using FastFood.Models;
6+
7+
public class FastFoodProfile : Profile
8+
{
9+
public FastFoodProfile()
10+
{
11+
//CreateMap<EmployeeDto, Employee>()
12+
// .ForPath(dest => dest.Position.Name, opt => opt.MapFrom(src => src.Position));
13+
14+
//CreateMap<ItemDto, Item>()
15+
// .ForPath(dest => dest.Category.Name, opt => opt.MapFrom(src => src.Category));
16+
}
17+
}
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-16"?>
2+
<Categories>
3+
<Category>
4+
<Name>Chicken</Name>
5+
<MostPopularItem>
6+
<Name>Chicken Tenders</Name>
7+
<TotalMade>44.00</TotalMade>
8+
<TimesSold>11</TimesSold>
9+
</MostPopularItem>
10+
</Category>
11+
<Category>
12+
<Name>Toys</Name>
13+
<MostPopularItem>
14+
<Name>Minion</Name>
15+
<TotalMade>24.20</TotalMade>
16+
<TimesSold>11</TimesSold>
17+
</MostPopularItem>
18+
</Category>
19+
<Category>
20+
<Name>Drinks</Name>
21+
<MostPopularItem>
22+
<Name>Purple Drink</Name>
23+
<TotalMade>9.10</TotalMade>
24+
<TimesSold>7</TimesSold>
25+
</MostPopularItem>
26+
</Category>
27+
</Categories>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Invalid data format.
2+
Invalid data format.
3+
Invalid data format.
4+
Invalid data format.
5+
Invalid data format.
6+
Record Magda Bjork successfully imported.
7+
Record Erich Hennigan successfully imported.
8+
Record Shin Vallejos successfully imported.
9+
Record Avery Rush successfully imported.
10+
Record Coral Points successfully imported.
11+
Record Xiao Raley successfully imported.
12+
Record Kym Douse successfully imported.
13+
Record Kendra Stangl successfully imported.
14+
Record Lura Yeldell successfully imported.
15+
Record Mohammad Norton successfully imported.
16+
Record Tamika Thornsberry successfully imported.
17+
Record Nancie Mcquarrie successfully imported.
18+
Record Maxwell Shanahan successfully imported.
19+
Record Classie Mettler successfully imported.
20+
Record Denita Providence successfully imported.
21+
Record Jerica Rupe successfully imported.
22+
Record Nolan Jablonski successfully imported.
23+
Record Mikki Vasques successfully imported.
24+
Record Ariane Sloan successfully imported.
25+
Record Herta Balser successfully imported.
26+
Record Jacqualine Clune successfully imported.
27+
Record Mervin Langone successfully imported.
28+
Record Dorethea Mumford successfully imported.
29+
Record Connie Barbosa successfully imported.
30+
Record Katie Nilsen successfully imported.
31+
Record Camille Peller successfully imported.
32+
Record Annett Lewallen successfully imported.
33+
Record Iris Foushee successfully imported.
34+
Record Eric Toole successfully imported.
35+
Record Justin Brazil successfully imported.
36+
Record Felisa Frier successfully imported.
37+
Record Lakiesha Huffines successfully imported.
38+
Record Emory Lemos successfully imported.
39+
Record Lanita Palmore successfully imported.
40+
Record Janiece Owens successfully imported.
41+
Record Maryland Palm successfully imported.
42+
Record Sunday Eastep successfully imported.
43+
Record Lucius Rotz successfully imported.
44+
Record Stanton Dahl successfully imported.
45+
Record Carmon Sesco successfully imported.
46+
Record Willette Ugalde successfully imported.
47+
Record Rose Blizzard successfully imported.
48+
Record Caridad Cuenca successfully imported.
49+
Record Tran Bullion successfully imported.
50+
Record Fred Higby successfully imported.
51+
Record Elizabet Trentham successfully imported.
52+
Record Shirleen Vonruden successfully imported.
53+
Record Oscar Dolan successfully imported.
54+
Record Prince Betton successfully imported.
55+
Record Jolanda Discher successfully imported.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Invalid data format.
2+
Invalid data format.
3+
Invalid data format.
4+
Invalid data format.
5+
Invalid data format.
6+
Invalid data format.
7+
Record Hamburger successfully imported.
8+
Invalid data format.
9+
Record Cheeseburger successfully imported.
10+
Record Quarter Pounder successfully imported.
11+
Record Double Cheeseburger successfully imported.
12+
Record Daily Double successfully imported.
13+
Record Ranger Burger successfully imported.
14+
Record BBQ Burger successfully imported.
15+
Record Bacon Deluxe successfully imported.
16+
Record Triple Cheeseburger successfully imported.
17+
Record Premium chicken sandwich successfully imported.
18+
Record Snack Wrap successfully imported.
19+
Record Premium Chicken Wrap successfully imported.
20+
Record Chicken Nuggets successfully imported.
21+
Record Crispy Chicken Deluxe successfully imported.
22+
Record Grilled Chicken Deluxe successfully imported.
23+
Record Tasty Basket successfully imported.
24+
Record Chicken Tenders successfully imported.
25+
Record Fries successfully imported.
26+
Record Crispy Fries successfully imported.
27+
Record Curly Fries successfully imported.
28+
Record Cola successfully imported.
29+
Record Orange Drink successfully imported.
30+
Record Purple Drink successfully imported.
31+
Record Ice Cream successfully imported.
32+
Record Cookie successfully imported.
33+
Record Cake successfully imported.
34+
Record Cesar Salad successfully imported.
35+
Record Tuna Salad successfully imported.
36+
Record Just Lettuce successfully imported.
37+
Record Minion successfully imported.
38+
Record Batman successfully imported.
39+
Record Mario successfully imported.
40+
Record Luigi successfully imported.
41+
Record Bowser successfully imported.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Order for Garry on 21/08/2017 13:22 added
2+
Order for Pablo on 23/11/2017 16:25 added
3+
Order for Enrique on 11/06/2017 14:08 added
4+
Order for Joann on 08/09/2017 23:19 added
5+
Order for Ray on 25/08/2017 20:13 added
6+
Order for Roberta on 02/03/2017 07:19 added
7+
Order for Daniel on 16/12/2017 20:13 added
8+
Order for Yolanda on 28/10/2017 04:25 added
9+
Order for Pablo on 26/03/2017 06:33 added
10+
Order for Ray on 11/03/2017 04:07 added
11+
Order for Bobbie on 09/02/2017 01:50 added
12+
Order for Miguel on 03/03/2017 21:41 added
13+
Order for Roberta on 26/09/2017 22:15 added
14+
Order for Leona on 06/02/2017 00:04 added
15+
Order for Stacey on 07/10/2017 06:00 added
16+
Order for Enrique on 19/07/2017 17:58 added
17+
Order for Guillermo on 23/08/2017 08:24 added
18+
Order for Darryl on 25/01/2017 13:02 added
19+
Order for Daniel on 24/05/2017 21:58 added
20+
Order for Bobbie on 08/04/2017 19:53 added
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"Name": "Avery Rush",
3+
"Orders": [
4+
{
5+
"Customer": "Stacey",
6+
"Items": [
7+
{
8+
"Name": "Cheeseburger",
9+
"Price": 6.00,
10+
"Quantity": 5
11+
},
12+
{
13+
"Name": "Double Cheeseburger",
14+
"Price": 6.50,
15+
"Quantity": 3
16+
},
17+
{
18+
"Name": "Luigi",
19+
"Price": 2.10,
20+
"Quantity": 5
21+
},
22+
{
23+
"Name": "Bacon Deluxe",
24+
"Price": 9.00,
25+
"Quantity": 1
26+
}
27+
],
28+
"TotalPrice": 69.00
29+
},
30+
{
31+
"Customer": "Pablo",
32+
"Items": [
33+
{
34+
"Name": "Double Cheeseburger",
35+
"Price": 6.50,
36+
"Quantity": 3
37+
},
38+
{
39+
"Name": "Bacon Deluxe",
40+
"Price": 9.00,
41+
"Quantity": 5
42+
}
43+
],
44+
"TotalPrice": 64.50
45+
},
46+
{
47+
"Customer": "Bobbie",
48+
"Items": [
49+
{
50+
"Name": "Tuna Salad",
51+
"Price": 3.00,
52+
"Quantity": 2
53+
},
54+
{
55+
"Name": "Crispy Fries",
56+
"Price": 2.00,
57+
"Quantity": 5
58+
},
59+
{
60+
"Name": "Fries",
61+
"Price": 1.50,
62+
"Quantity": 2
63+
}
64+
],
65+
"TotalPrice": 19.00
66+
},
67+
{
68+
"Customer": "Joann",
69+
"Items": [
70+
{
71+
"Name": "Minion",
72+
"Price": 2.20,
73+
"Quantity": 2
74+
},
75+
{
76+
"Name": "Bacon Deluxe",
77+
"Price": 9.00,
78+
"Quantity": 1
79+
}
80+
],
81+
"TotalPrice": 13.40
82+
}
83+
],
84+
"TotalMade": 165.90
85+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using System.Data.SqlClient;
3+
using System.IO;
4+
using AutoMapper;
5+
using FastFood.Data;
6+
using FastFood.DataProcessor;
7+
using Microsoft.EntityFrameworkCore;
8+
using Newtonsoft.Json;
9+
10+
namespace FastFood.App
11+
{
12+
public class Startup
13+
{
14+
public static void Main(string[] args)
15+
{
16+
var context = new FastFoodDbContext();
17+
18+
ResetDatabase(context);
19+
20+
Console.WriteLine("Database Reset.");
21+
22+
Mapper.Initialize(cfg => cfg.AddProfile<FastFoodProfile>());
23+
24+
ImportEntities(context);
25+
26+
ExportEntities(context);
27+
28+
BonusTask(context);
29+
}
30+
31+
private static void ImportEntities(FastFoodDbContext context, string baseDir = @"C:\Users\Petya\Desktop\SoftUniPavel\ExamPrep\FastFood.DataProcessor\Datasets\")
32+
{
33+
const string exportDir = @"C:\Users\Petya\Desktop\SoftUniPavel\ExamPrep\FastFood.App\ImportResults\";
34+
35+
var employees = DataProcessor.Deserializer.ImportEmployees(context, File.ReadAllText(baseDir + "employees.json"));
36+
PrintAndExportEntityToFile(employees, exportDir + "Employees.txt");
37+
38+
var items = DataProcessor.Deserializer.ImportItems(context, File.ReadAllText(baseDir + "items.json"));
39+
PrintAndExportEntityToFile(items, exportDir + "Items.txt");
40+
41+
var orders = DataProcessor.Deserializer.ImportOrders(context, File.ReadAllText(baseDir + "orders.xml"));
42+
PrintAndExportEntityToFile(orders, exportDir + "Orders.txt");
43+
}
44+
45+
private static void ExportEntities(FastFoodDbContext context)
46+
{
47+
const string exportDir = @"C:\Users\Petya\Desktop\SoftUniPavel\ExamPrep\FastFood.App\ImportResults\";
48+
49+
var jsonOutput = DataProcessor.Serializer.ExportOrdersByEmployee(context, "Avery Rush", "ToGo");
50+
Console.WriteLine(jsonOutput);
51+
File.WriteAllText(exportDir + "OrdersByEmployee.json", jsonOutput);
52+
53+
var xmlOutput = DataProcessor.Serializer.ExportCategoryStatistics(context, "Chicken,Drinks,Toys");
54+
Console.WriteLine(xmlOutput);
55+
File.WriteAllText(exportDir + "CategoryStatistics.xml", xmlOutput);
56+
}
57+
58+
private static void BonusTask(FastFoodDbContext context)
59+
{
60+
var bonusOutput = DataProcessor.Bonus.UpdatePrice(context, "Cheeseburger", 6.50m);
61+
Console.WriteLine(bonusOutput);
62+
}
63+
64+
private static void PrintAndExportEntityToFile(string entityOutput, string outputPath)
65+
{
66+
Console.WriteLine(entityOutput);
67+
File.WriteAllText(outputPath, entityOutput.TrimEnd());
68+
}
69+
70+
private static void ResetDatabase(FastFoodDbContext context)
71+
{
72+
context.Database.EnsureDeleted();
73+
context.Database.EnsureCreated();
74+
}
75+
}
76+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FastFood.Data
2+
{
3+
public static class Configuration
4+
{
5+
public static string ConnectionString = @"Server=.;Database=FastFood;Trusted_Connection=True";
6+
}
7+
}

0 commit comments

Comments
 (0)