diff --git a/SmallSoftwareProject/SmallSoftwareContracts/DataModels/InstallationRequestDataModel.cs b/SmallSoftwareProject/SmallSoftwareContracts/DataModels/InstallationRequestDataModel.cs index ab2aae1..4f2aaa8 100644 --- a/SmallSoftwareProject/SmallSoftwareContracts/DataModels/InstallationRequestDataModel.cs +++ b/SmallSoftwareProject/SmallSoftwareContracts/DataModels/InstallationRequestDataModel.cs @@ -4,11 +4,12 @@ using SmallSoftwareContracts.Infrastructure; namespace SmallSoftwareContracts.DataModels; -public class InstallationRequestDataModel(string softwareId, string requestId, int count) : IValidation +public class InstallationRequestDataModel(string softwareId, string requestId, int count, double price) : IValidation { public string SoftwareId { get; private set; } = softwareId; public string RequestId { get; private set; } = requestId; - public int Count { get; private set; } = count; + public int Count { get; private set; } = count; + public double Price { get; private set; } = price; public void Validate() { if (SoftwareId.IsEmpty()) @@ -21,5 +22,7 @@ public class InstallationRequestDataModel(string softwareId, string requestId, i throw new ValidationException("The value in the field RequestId is not a unique identifier"); if (Count <= 0) throw new ValidationException("Field Count is less than or equal to 0"); + if (Price <= 0) + throw new ValidationException("Field Price is less than or equal to 0"); } } diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/InstallationRequest.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/InstallationRequest.cs new file mode 100644 index 0000000..b7c8ea1 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/InstallationRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class InstallationRequest +{ + public required string SoftwareId { get; set; } + public required string RequestId { get; set; } + public int Count { get; set; } + public double Price { get; set; } + public Request? Request { get; set; } + public Software? Software { get; set; } + +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Manufacturer.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Manufacturer.cs new file mode 100644 index 0000000..3d44eb1 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Manufacturer.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Manufacturer +{ + public required string Id { get; set; } + public required string ManufacturerName { get; set; } + public string? PrevManufacturerName { get; set; } + public string? PrevPrevManufacturerName { get; set; } + + [ForeignKey("ManufacturerId")] + public List? Softwares { get; set; } + +} \ No newline at end of file diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Post.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Post.cs new file mode 100644 index 0000000..a268c54 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Post.cs @@ -0,0 +1,19 @@ +using SmallSoftwareContracts.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Post +{ + public string Id { get; set; } = Guid.NewGuid().ToString(); + public required string PostId { get; set; } + public required string PostName { get; set; } + public PostType PostType { get; set; } + public double Salary { get; set; } + public bool IsActual { get; set; } + public DateTime ChangeDate { get; set; } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Request.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Request.cs new file mode 100644 index 0000000..64cd22f --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Request.cs @@ -0,0 +1,22 @@ +using SmallSoftwareContracts.DataModels; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Request +{ + public required string Id { get; set; } = Guid.NewGuid().ToString(); + public required string WorkerId { get; set; } + public required string Email { get; set; } + public double Sum { get; set; } + public bool IsCancel { get; set; } + public Worker? Worker { get; set; } + + [ForeignKey("RequestId")] + public List? InstallationRequests { get; set; } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Salary.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Salary.cs new file mode 100644 index 0000000..dfc4272 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Salary.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Salary +{ + public string Id { get; set; } = Guid.NewGuid().ToString(); + public required string WorkerId { get; set; } + public double WorkerSalary { get; set; } + public DateTime SalaryDate { get; set; } + public Worker? Worker { get; set; } +} + diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Software.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Software.cs new file mode 100644 index 0000000..59d8a36 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Software.cs @@ -0,0 +1,29 @@ +using SmallSoftwareContracts.Enums; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Software +{ + public required string Id { get; set; } + public required string SoftwareName { get; set; } + public SoftwareType SoftwareType { get; set; } + public required string ManufacturerId { get; set; } + public double Price { get; set; } + public bool IsDeleted { get; set; } + public string? PrevSoftwareName { get; set; } + public string? PrevPrevSoftwareName { get; set; } + public Manufacturer? Manufacturer { get; set; } + + [ForeignKey("SoftwareId")] + public List? SoftwareHistories { get; set; } + + [ForeignKey("SoftwareId")] + public List? InstallationRequests { get; set; } + +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/SoftwareHistory.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/SoftwareHistory.cs new file mode 100644 index 0000000..dcac6e4 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/SoftwareHistory.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class SoftwareHistory +{ + public string Id { get; set; } = Guid.NewGuid().ToString(); + public required string SoftwareId { get; set; } + public double OldPrice { get; set; } + public DateTime ChangeDate { get; set; } = DateTime.UtcNow; + + public Software? Software { get; set; } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Models/Worker.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Worker.cs new file mode 100644 index 0000000..96c2af1 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Models/Worker.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase.Models; + +internal class Worker +{ + public required string Id { get; set; } + public required string FIO { get; set; } + public required string PostId { get; set; } + public DateTime BirthDate { get; set; } + public DateTime EmploymentDate { get; set; } + public bool IsDeleted { get; set; } + + [ForeignKey("WorkerId")] + public List? Salaries { get; set; } + [ForeignKey("WorkerId")] + public List? Requests { get; set; } + +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj b/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj new file mode 100644 index 0000000..21aab05 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/SmallSoftwareProject/SmallSoftwareProject.sln b/SmallSoftwareProject/SmallSoftwareProject.sln index 4a6b6cb..b3735e2 100644 --- a/SmallSoftwareProject/SmallSoftwareProject.sln +++ b/SmallSoftwareProject/SmallSoftwareProject.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareTests", "Small EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareBusinessLogic", "SmallSoftwareBusinessLogic\SmallSoftwareBusinessLogic.csproj", "{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareDatabase", "SmallSoftwareDatabase\SmallSoftwareDatabase.csproj", "{59771C74-7A34-4354-949A-F3AA071FBCAA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Release|Any CPU.Build.0 = Release|Any CPU + {59771C74-7A34-4354-949A-F3AA071FBCAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59771C74-7A34-4354-949A-F3AA071FBCAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59771C74-7A34-4354-949A-F3AA071FBCAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59771C74-7A34-4354-949A-F3AA071FBCAA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE