-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c42824
commit a8ac6a3
Showing
75 changed files
with
15,740 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Import\cars.xml" /> | ||
<None Remove="Import\customers.xml" /> | ||
<None Remove="Import\parts.xml" /> | ||
<None Remove="Import\suppliers.xml" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Import\cars.xml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Import\customers.xml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Import\parts.xml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Import\suppliers.xml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="automapper" Version="8.0.0" /> | ||
<PackageReference Include="microsoft.entityframeworkcore.sqlserver" Version="2.2.3" /> | ||
<PackageReference Include="microsoft.entityframeworkcore.tools" Version="2.2.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Export\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer | ||
{ | ||
using AutoMapper; | ||
using CarDealer.Dtos; | ||
using CarDealer.Models; | ||
|
||
public class CarDealerProfile : Profile | ||
{ | ||
public CarDealerProfile() | ||
{ | ||
CreateMap<ImportSupplierDto, Supplier>(); | ||
CreateMap<ImportCustomersDto, Customer>(); | ||
CreateMap<ImportCarDto, Car>(); | ||
CreateMap<ImportPartDto, Part>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace CarDealer.Data | ||
{ | ||
using CarDealer.Data.EntityConfigurations; | ||
using CarDealer.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
public class CarDealerContext : DbContext | ||
{ | ||
public CarDealerContext() | ||
{ | ||
} | ||
|
||
public CarDealerContext(DbContextOptions options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
public DbSet<Car> Cars { get; set; } | ||
public DbSet<Customer> Customers { get; set; } | ||
public DbSet<Part> Parts { get; set; } | ||
public DbSet<PartCars> PartCars { get; set; } | ||
public DbSet<Sale> Sales { get; set; } | ||
public DbSet<Supplier> Suppliers { get; set; } | ||
|
||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
if (!optionsBuilder.IsConfigured) | ||
{ | ||
optionsBuilder.UseSqlServer("Server=.;Database=CarDealer;Integrated Security=True;"); | ||
} | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.ApplyConfiguration(new SaleConfig()); | ||
modelBuilder.ApplyConfiguration(new PartConfig()); | ||
modelBuilder.ApplyConfiguration(new PartCarsConfig()); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
12.XML Processing/CarDealer/Data/EntityConfigurations/PartCarsConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace CarDealer.Data.EntityConfigurations | ||
{ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
using Models; | ||
|
||
public class PartCarsConfig : IEntityTypeConfiguration<PartCars> | ||
{ | ||
public void Configure(EntityTypeBuilder<PartCars> builder) | ||
{ | ||
builder.HasKey(x => new { x.CarId, x.PartId }); | ||
|
||
builder.HasOne(pc => pc.Car) | ||
.WithMany(c => c.PartCars) | ||
.HasForeignKey(pc => pc.CarId); | ||
|
||
builder.HasOne(pc => pc.Part) | ||
.WithMany(c => c.PartCars) | ||
.HasForeignKey(pc => pc.PartId); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
12.XML Processing/CarDealer/Data/EntityConfigurations/PartConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Data.EntityConfigurations | ||
{ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
using Models; | ||
|
||
public class PartConfig : IEntityTypeConfiguration<Part> | ||
{ | ||
public void Configure(EntityTypeBuilder<Part> builder) | ||
{ | ||
builder.HasOne(x => x.Supplier) | ||
.WithMany(s => s.Parts) | ||
.HasForeignKey(x => x.SupplierId); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
12.XML Processing/CarDealer/Data/EntityConfigurations/SaleConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace CarDealer.Data.EntityConfigurations | ||
{ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
using Models; | ||
|
||
public class SaleConfig : IEntityTypeConfiguration<Sale> | ||
{ | ||
public void Configure(EntityTypeBuilder<Sale> builder) | ||
{ | ||
builder.HasOne(x => x.Car) | ||
.WithMany(c => c.Sales) | ||
.HasForeignKey(x => x.CarId); | ||
|
||
builder.HasOne(x => x.Customer) | ||
.WithMany(c => c.Sales) | ||
.HasForeignKey(x => x.CustomerId); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
12.XML Processing/CarDealer/Dtos/ExerciseFiveDto/SalesByCustomerDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos.ExerciseFiveDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("customer")] | ||
public class SalesByCustomerDto | ||
{ | ||
[XmlAttribute("full-name")] | ||
public string FullName { get; set; } | ||
|
||
[XmlAttribute("bought-cars")] | ||
public int BoughtCarsCount { get; set; } | ||
|
||
[XmlAttribute("spent-money")] | ||
public decimal SpentMoney { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
12.XML Processing/CarDealer/Dtos/ExerciseFourDto/CarDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Xml.Serialization; | ||
|
||
namespace CarDealer.Dtos.ExerciseFourDto | ||
{ | ||
[XmlType("car")] | ||
public class CarDto | ||
{ | ||
[XmlAttribute("make")] | ||
public string Make { get; set; } | ||
|
||
[XmlAttribute("model")] | ||
public string Model { get; set; } | ||
|
||
[XmlAttribute("travelled-distance")] | ||
public long TravelledDistance{ get; set; } | ||
|
||
[XmlArray("parts")] | ||
public PartDto[] Parts { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
12.XML Processing/CarDealer/Dtos/ExerciseFourDto/PartDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace CarDealer.Dtos.ExerciseFourDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("part")] | ||
public class PartDto | ||
{ | ||
[XmlAttribute("name")] | ||
public string Name { get; set; } | ||
|
||
[XmlAttribute("price")] | ||
public decimal Price { get; set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
12.XML Processing/CarDealer/Dtos/ExerciseSixDto/SaleCarDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos.ExerciseSixDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("car")] | ||
public class SaleCarDto | ||
{ | ||
[XmlAttribute("make")] | ||
public string Make { get; set; } | ||
|
||
[XmlAttribute("model")] | ||
public string Model { get; set; } | ||
|
||
[XmlAttribute("travelled-distance")] | ||
public long TravelledDistance { get; set; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
12.XML Processing/CarDealer/Dtos/ExerciseSixDto/SaleDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace CarDealer.Dtos.ExerciseSixDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("sale")] | ||
public class SaleDto | ||
{ | ||
[XmlElement("car")] | ||
public SaleCarDto Carr { get; set; } | ||
|
||
[XmlElement("customer-name")] | ||
public string FullName { get; set; } | ||
|
||
[XmlElement("discount")] | ||
public double Discount { get; set; } | ||
|
||
[XmlElement("price")] | ||
public decimal Price { get; set; } | ||
|
||
[XmlElement("price-with-discount")] | ||
public decimal PriceWothDiscount { get; set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
12.XML Processing/CarDealer/Dtos/ExerciseThreeDto/LocalSupplierDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos.ExerciseThreeDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("supplier")] | ||
public class LocalSupplierDto | ||
{ | ||
[XmlAttribute("id")] | ||
public int Id { get; set; } | ||
|
||
[XmlAttribute("name")] | ||
public string Name { get; set; } | ||
|
||
[XmlAttribute("parts-count")] | ||
public int PartsCount { get; set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
12.XML Processing/CarDealer/Dtos/ExerciseTwoDto/FerrariCarDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos.ExerciseTwoDto | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("car")] | ||
public class FerrariCarDto | ||
{ | ||
[XmlAttribute("id")] | ||
public int Id { get; set; } | ||
|
||
[XmlAttribute("model")] | ||
public string Model { get; set; } | ||
|
||
[XmlAttribute("travelled-distance")] | ||
public long TravelledDistance{ get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("car")] | ||
public class ImportCarDto | ||
{ | ||
[XmlElement("make")] | ||
public string Make { get; set; } | ||
|
||
[XmlElement("model")] | ||
public string Model { get; set; } | ||
|
||
[XmlElement("travelled-distance")] | ||
public long TravelledDistance { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace CarDealer.Dtos | ||
{ | ||
using System; | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("customer")] | ||
public class ImportCustomersDto | ||
{ | ||
[XmlAttribute("name")] | ||
public string Name { get; set; } | ||
|
||
[XmlElement("birth-date")] | ||
public DateTime BirthDate { get; set; } | ||
|
||
[XmlElement("is-young-driver")] | ||
public bool IsYoungDriver { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CarDealer.Dtos | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("part")] | ||
public class ImportPartDto | ||
{ | ||
[XmlAttribute("name")] | ||
public string Name { get; set; } | ||
|
||
[XmlAttribute("price")] | ||
public decimal Price { get; set; } | ||
|
||
[XmlAttribute("quantity")] | ||
public int Quantity { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace CarDealer.Dtos | ||
{ | ||
using System.Xml.Serialization; | ||
|
||
[XmlType("supplier")] | ||
public class ImportSupplierDto | ||
{ | ||
[XmlAttribute("name")] | ||
public string Name { get; set; } | ||
|
||
[XmlAttribute("is-importer")] | ||
public bool IsImporter { get; set; } | ||
} | ||
} |
Oops, something went wrong.