-
Notifications
You must be signed in to change notification settings - Fork 72
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
Showing
116 changed files
with
3,842 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership.sln
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dealership", "Dealership\Dealership.csproj", "{4DB3664E-CDAE-446D-8163-683F6344C24B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
58 changes: 58 additions & 0 deletions
58
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Constants.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,58 @@ | ||
namespace Dealership.Common | ||
{ | ||
public class Constants | ||
{ | ||
// String lengths | ||
public const int MinNameLength = 2; | ||
public const int MaxNameLength = 20; | ||
public const int MinPasswordLength = 5; | ||
public const int MaxPasswordLength = 30; | ||
public const int MinCategoryLength = 3; | ||
public const int MaxCategoryLength = 10; | ||
public const int MinMakeLength = 2; | ||
public const int MaxMakeLength = 15; | ||
public const int MinModelLength = 1; | ||
public const int MaxModelLength = 15; | ||
public const int MinCommentLength = 3; | ||
public const int MaxCommentLength = 200; | ||
|
||
// Numbers validation | ||
public const int MinWheels = 2; | ||
public const int MaxWheels = 10; | ||
public const decimal MinPrice = 0.0m; | ||
public const decimal MaxPrice = 1000000.0m; | ||
public const int MinSeats = 1; | ||
public const int MaxSeats = 10; | ||
public const int MinCapacity = 1; | ||
public const int MaxCapacity = 100; | ||
|
||
// Strings for validation | ||
public const string StringMustBeBetweenMinAndMax = "{0} must be between {1} and {2} characters long!"; | ||
public const string NumberMustBeBetweenMinAndMax = "{0} must be between {1} and {2}!"; | ||
|
||
// Vehicle max to add if not VIP | ||
public const int MaxVehiclesToAdd = 5; | ||
|
||
// Username pattern | ||
public const string UsernamePattern = "^[A-Za-z0-9]+$"; | ||
public const string PasswordPattern = "^[A-Za-z0-9@*_-]+$"; | ||
|
||
// Strings for vehicles, comments and users | ||
public const string InvalidSymbols = "{0} contains invalid symbols!"; | ||
|
||
public const string UserToString = "Username: {0}, FullName: {1} {2}, Role: {3}"; | ||
|
||
public const string CommentCannotBeNull = "Comment cannot be null!"; | ||
public const string VehicleCannotBeNull = "Vehicle cannot be null!"; | ||
|
||
public const string NotAnVipUserVehiclesAdd = "You are not VIP and cannot add more than {0} vehicles!"; | ||
public const string AdminCannotAddVehicles = "You are an admin and therefore cannot add vehicles!"; | ||
|
||
public const string YouAreNotTheAuthor = "You are not the author!"; | ||
public const string UserCannotBeNull = "User cannot be null!"; | ||
|
||
// Added additionally | ||
public const string PropertyCannotBeNull = "{0} cannot be null!"; | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/Role.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,9 @@ | ||
namespace Dealership.Common.Enums | ||
{ | ||
public enum Role | ||
{ | ||
Normal = 0, | ||
VIP = 1, | ||
Admin = 2 | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...cs/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/VehicleType.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,9 @@ | ||
namespace Dealership.Common.Enums | ||
{ | ||
public enum VehicleType | ||
{ | ||
Motorcycle = 2, | ||
Car = 4, | ||
Truck = 8 | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Validator.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,42 @@ | ||
namespace Dealership.Common | ||
{ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
|
||
public static class Validator | ||
{ | ||
public static void ValidateIntRange(int value, int min, int max, string message) | ||
{ | ||
if (value < min || value > max) | ||
{ | ||
throw new ArgumentException(message); | ||
} | ||
} | ||
|
||
public static void ValidateDecimalRange(decimal value, decimal min, decimal max, string message) | ||
{ | ||
if (value < min || value > max) | ||
{ | ||
throw new ArgumentException(message); | ||
} | ||
} | ||
|
||
public static void ValidateNull(object value, string message) | ||
{ | ||
if (value == null) | ||
{ | ||
throw new ArgumentNullException(message); | ||
} | ||
} | ||
|
||
public static void ValidateSymbols(string value, string pattern, string message) | ||
{ | ||
var regex = new Regex(pattern, RegexOptions.IgnoreCase); | ||
|
||
if (!regex.IsMatch(value)) | ||
{ | ||
throw new ArgumentException(message); | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICar.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,7 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
public interface ICar | ||
{ | ||
int Seats { get; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IComment.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,9 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
public interface IComment | ||
{ | ||
string Content { get; } | ||
|
||
string Author { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICommentable.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,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Dealership.Contracts | ||
{ | ||
public interface ICommentable | ||
{ | ||
IList<IComment> Comments { get; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IMotorcycle.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,7 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
public interface IMotorcycle | ||
{ | ||
string Category { get; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IPriceable.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,7 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
public interface IPriceable | ||
{ | ||
decimal Price { get; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ITruck.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,7 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
public interface ITruck | ||
{ | ||
int WeightCapacity { get; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IUser.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,30 @@ | ||
using Dealership.Common.Enums; | ||
using System.Collections.Generic; | ||
|
||
namespace Dealership.Contracts | ||
{ | ||
public interface IUser | ||
{ | ||
string Username { get; } | ||
|
||
string FirstName { get; } | ||
|
||
string LastName { get; } | ||
|
||
string Password { get; } | ||
|
||
Role Role { get; } | ||
|
||
IList<IVehicle> Vehicles { get; } | ||
|
||
void AddVehicle(IVehicle vehicle); | ||
|
||
void RemoveVehicle(IVehicle vehicle); | ||
|
||
void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment); | ||
|
||
void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment); | ||
|
||
string PrintVehicles(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IVehicle.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,15 @@ | ||
namespace Dealership.Contracts | ||
{ | ||
using Dealership.Common.Enums; | ||
|
||
public interface IVehicle : ICommentable, IPriceable | ||
{ | ||
int Wheels { get; } | ||
|
||
VehicleType Type { get; } | ||
|
||
string Make { get; } | ||
|
||
string Model { get; } | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Dealership.csproj
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,82 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{4DB3664E-CDAE-446D-8163-683F6344C24B}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Dealership</RootNamespace> | ||
<AssemblyName>Dealership</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Common\Constants.cs" /> | ||
<Compile Include="Common\Enums\VehicleType.cs" /> | ||
<Compile Include="Common\Enums\Role.cs" /> | ||
<Compile Include="Common\Validator.cs" /> | ||
<Compile Include="Contracts\ICar.cs" /> | ||
<Compile Include="Contracts\IComment.cs" /> | ||
<Compile Include="Contracts\ICommentable.cs" /> | ||
<Compile Include="Contracts\IMotorcycle.cs" /> | ||
<Compile Include="Contracts\IPriceable.cs" /> | ||
<Compile Include="Contracts\ITruck.cs" /> | ||
<Compile Include="Contracts\IUser.cs" /> | ||
<Compile Include="Contracts\IVehicle.cs" /> | ||
<Compile Include="Engine\Command.cs" /> | ||
<Compile Include="Engine\DealershipEngine.cs" /> | ||
<Compile Include="Engine\ICommand.cs" /> | ||
<Compile Include="Engine\IEngine.cs" /> | ||
<Compile Include="Factories\DealershipFactory.cs" /> | ||
<Compile Include="Factories\IDealershipFactory.cs" /> | ||
<Compile Include="Models\Car.cs" /> | ||
<Compile Include="Models\Comment.cs" /> | ||
<Compile Include="Models\Motorcycle.cs" /> | ||
<Compile Include="Models\Truck.cs" /> | ||
<Compile Include="Models\User.cs" /> | ||
<Compile Include="Models\Vehicle.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Startup.cs" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.