diff --git a/TheWingsOfTheWorldProject.sln b/TheWingsOfTheWorldProject.sln new file mode 100644 index 0000000..ce0e633 --- /dev/null +++ b/TheWingsOfTheWorldProject.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35806.99 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WingsOfTheWorldContratcs", "WingsOfTheWorldContratcs\WingsOfTheWorldContratcs.csproj", "{BEAC542F-7E06-4942-A37D-583E87FAE7FF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BEAC542F-7E06-4942-A37D-583E87FAE7FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEAC542F-7E06-4942-A37D-583E87FAE7FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEAC542F-7E06-4942-A37D-583E87FAE7FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEAC542F-7E06-4942-A37D-583E87FAE7FF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FDD9A46D-B6D6-40D9-AE18-3DF8480C20EB} + EndGlobalSection +EndGlobal diff --git a/WingsOfTheWorldContratcs/DataModels/AccessoriesDataModel.cs b/WingsOfTheWorldContratcs/DataModels/AccessoriesDataModel.cs new file mode 100644 index 0000000..0a40fe1 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/AccessoriesDataModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Enums; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class AccessoriesDataModel(string id, string name, AccessoriesType accessoriesType) : IValidation +{ + public string Id { get; private set; } = id; + + public string Name { get; private set; } = name; + + public AccessoriesType AccessoriesType { get; private set; } = accessoriesType; + + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (Name.IsEmpty()) + throw new ValidationException("Field PostName is empty"); + + if (AccessoriesType == AccessoriesType.None) + throw new ValidationException("Field PostType is empty"); + + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/AirplaneDataModel.cs b/WingsOfTheWorldContratcs/DataModels/AirplaneDataModel.cs new file mode 100644 index 0000000..609ca56 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/AirplaneDataModel.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class AirplaneDataModel(string id, string model) : IValidation +{ + public string Id { get; private set; } = id; + public string Model { get; private set; } = model; + + + + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (Model.IsEmpty()) + throw new ValidationException("Field Model is empty"); + + if (!Model.IsGuid()) + throw new ValidationException("The value in the field Model is not a unique identifier"); + + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/DeliveryDataModel.cs b/WingsOfTheWorldContratcs/DataModels/DeliveryDataModel.cs new file mode 100644 index 0000000..196e082 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/DeliveryDataModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class DeliveryDataModel(string id, string airPlaneId, string place, int count, int price) : IValidation +{ + + public string Id { get; private set; } = id; + + public string AirPlaneId { get; private set; } = airPlaneId; + + public string Place { get; private set; } = place; + + public int Count { get; private set; } = count; + + public int Price { get; private set; } = price; + + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (AirPlaneId.IsEmpty()) + throw new ValidationException("Field AirPlaneId is empty"); + + if (!AirPlaneId.IsGuid()) + throw new ValidationException("The value in the field AirPlaneId is not a unique identifier"); + + if (Place.IsEmpty()) + throw new ValidationException("Field Place is empty"); + + if (!Place.IsGuid()) + throw new ValidationException("The value in the field Place is not a unique identifier"); + + if (Count <= 0) + throw new ValidationException("Field Count is empty"); + + if (Price <= 0) + throw new ValidationException("Field Price is empty"); + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/DeliveryHistoryDataModel.cs b/WingsOfTheWorldContratcs/DataModels/DeliveryHistoryDataModel.cs new file mode 100644 index 0000000..257755b --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/DeliveryHistoryDataModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class DeliveryHistoryDataModel(string airplaneid, double oldPrice) : IValidation +{ + public string AirplaneId { get; private set; } = airplaneid; + + public double OldPrice { get; private set; } = oldPrice; + + public DateTime ChangeDate { get; private set; } = DateTime.UtcNow; + + public void Validate() + { + if (AirplaneId.IsEmpty()) + throw new ValidationException("Field ProductId is empty"); + + if (!AirplaneId.IsGuid()) + throw new ValidationException("The value in the field ProductId is not a unique identifier"); + + if (OldPrice <= 0) + throw new ValidationException("Field OldPrice is less than or equal to 0"); + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/PostDataModel.cs b/WingsOfTheWorldContratcs/DataModels/PostDataModel.cs new file mode 100644 index 0000000..16a2be9 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/PostDataModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Enums; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class PostDataModel(string id, string postId, string postName, PostType postType, double salary, bool isActual, DateTime changeDate) : IValidation +{ + public string Id { get; private set; } = id; + + public string PostId { get; private set; } = postId; + + public string PostName { get; private set; } = postName; + + public PostType PostType { get; private set; } = postType; + + public double Salary { get; private set; } = salary; + + public bool IsActual { get; private set; } = isActual; + + public DateTime ChangeDate { get; private set; } = changeDate; + + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (PostId.IsEmpty()) + throw new ValidationException("Field PostId is empty"); + + if (!PostId.IsGuid()) + throw new ValidationException("The value in the field PostId is not a unique identifier"); + + if (PostName.IsEmpty()) + throw new ValidationException("Field PostName is empty"); + + if (PostType == PostType.None) + throw new ValidationException("Field PostType is empty"); + + if (Salary <= 0) + throw new ValidationException("Field Salary is empty"); + } +} + diff --git a/WingsOfTheWorldContratcs/DataModels/SalaryDataModel.cs b/WingsOfTheWorldContratcs/DataModels/SalaryDataModel.cs new file mode 100644 index 0000000..b4d4d66 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/SalaryDataModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary) : IValidation +{ + public string WorkerId { get; private set; } = workerId; + + public DateTime SalaryDate { get; private set; } = salaryDate; + + public double Salary { get; private set; } = workerSalary; + + public void Validate() + { + if (WorkerId.IsEmpty()) + throw new ValidationException("Field WorkerId is empty"); + + if (!WorkerId.IsGuid()) + throw new ValidationException("The value in the field WorkerId is not a unique identifier"); + + if (Salary <= 0) + throw new ValidationException("Field Salary is less than or equal to 0"); + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/WorkerDataModel.cs b/WingsOfTheWorldContratcs/DataModels/WorkerDataModel.cs new file mode 100644 index 0000000..a0fea54 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/WorkerDataModel.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class WorkerDataModel(string id, string fio, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation +{ + public string Id { get; private set; } = id; + + public string FIO { get; private set; } = fio; + + public string PostId { get; private set; } = postId; + + public DateTime BirthDate { get; private set; } = birthDate; + + public DateTime EmploymentDate { get; private set; } = employmentDate; + + public bool IsDeleted { get; private set; } = isDeleted; + + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (FIO.IsEmpty()) + throw new ValidationException("Field FIO is empty"); + + if (PostId.IsEmpty()) + throw new ValidationException("Field PostId is empty"); + + if (!PostId.IsGuid()) + throw new ValidationException("The value in the field PostId is not a unique identifier"); + + if (BirthDate.Date > DateTime.Now.AddYears(-16).Date) + throw new ValidationException($"Minors cannot be hired (BirthDate = {BirthDate.ToShortDateString()})"); + + if (EmploymentDate.Date < BirthDate.Date) + throw new ValidationException("The date of employment cannot be less than the date of birth"); + + if ((EmploymentDate - BirthDate).TotalDays / 365 < 16) // EmploymentDate.Year - BirthDate.Year + throw new ValidationException($"Minors cannot be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})"); + } +} diff --git a/WingsOfTheWorldContratcs/DataModels/СarrierСompanyDataModel.cs b/WingsOfTheWorldContratcs/DataModels/СarrierСompanyDataModel.cs new file mode 100644 index 0000000..6e2abd7 --- /dev/null +++ b/WingsOfTheWorldContratcs/DataModels/СarrierСompanyDataModel.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WingsOfTheWorldContratcs.Exceptions; +using WingsOfTheWorldContratcs.Exstensions; +using WingsOfTheWorldContratcs.Infrastructure; + +namespace WingsOfTheWorldContratcs.DataModels; + +public class СarrierСompanyDataModel(string id, string name, string phoneNumber, int count, int price) : IValidation +{ + public string Id { get; private set; } = id; + + public string Name { get; private set; } = name; + + public string PhoneNumber { get; private set; } = phoneNumber; + + public int Count { get; private set; } = count; + + public int Price { get; private set; } = price; + public void Validate() + { + if (Id.IsEmpty()) + throw new ValidationException("Field Id is empty"); + + if (!Id.IsGuid()) + throw new ValidationException("The value in the field Id is not a unique identifier"); + + if (Name.IsEmpty()) + throw new ValidationException("Field Name is empty"); + + if (PhoneNumber.IsEmpty()) + throw new ValidationException("Field PhoneNumber is empty"); + + if (!Regex.IsMatch(PhoneNumber, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$")) + throw new ValidationException("Field PhoneNumber is not a phone number"); + + if (Count <= 0) + throw new ValidationException("Field Count is empty"); + + if (Price <= 0) + throw new ValidationException("Field Price is empty"); + } +} diff --git a/WingsOfTheWorldContratcs/Enums/AccessoriesType.cs b/WingsOfTheWorldContratcs/Enums/AccessoriesType.cs new file mode 100644 index 0000000..3ebd5e7 --- /dev/null +++ b/WingsOfTheWorldContratcs/Enums/AccessoriesType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WingsOfTheWorldContratcs.Enums; + +public enum AccessoriesType +{ + None = 0, + Accessories = 1, + Salon = 2, + BodyWork = 3 +} diff --git a/WingsOfTheWorldContratcs/Enums/PostType.cs b/WingsOfTheWorldContratcs/Enums/PostType.cs new file mode 100644 index 0000000..cb00b13 --- /dev/null +++ b/WingsOfTheWorldContratcs/Enums/PostType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WingsOfTheWorldContratcs.Enums; + +public enum PostType +{ + None = 0, + Supervisor = 1, + Master = 2, + Assistent = 3 +} diff --git a/WingsOfTheWorldContratcs/Exceptions/ValidationException.cs b/WingsOfTheWorldContratcs/Exceptions/ValidationException.cs new file mode 100644 index 0000000..c61aed4 --- /dev/null +++ b/WingsOfTheWorldContratcs/Exceptions/ValidationException.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WingsOfTheWorldContratcs.Exceptions; + +public class ValidationException(string message) : Exception(message) +{ +} diff --git a/WingsOfTheWorldContratcs/Exstensions/StringExstensions.cs b/WingsOfTheWorldContratcs/Exstensions/StringExstensions.cs new file mode 100644 index 0000000..bf50945 --- /dev/null +++ b/WingsOfTheWorldContratcs/Exstensions/StringExstensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WingsOfTheWorldContratcs.Exstensions; + +public static class StringExstensions +{ + public static bool IsEmpty(this string str) + { + return string.IsNullOrWhiteSpace(str); + } + + public static bool IsGuid(this string str) + { + return Guid.TryParse(str, out _); + } +} diff --git a/WingsOfTheWorldContratcs/Infrastructure/IValidation.cs b/WingsOfTheWorldContratcs/Infrastructure/IValidation.cs new file mode 100644 index 0000000..aea3890 --- /dev/null +++ b/WingsOfTheWorldContratcs/Infrastructure/IValidation.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WingsOfTheWorldContratcs.Infrastructure; + +public interface IValidation +{ + void Validate(); +} diff --git a/WingsOfTheWorldContratcs/WingsOfTheWorldContratcs.csproj b/WingsOfTheWorldContratcs/WingsOfTheWorldContratcs.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/WingsOfTheWorldContratcs/WingsOfTheWorldContratcs.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + +