project_db + models
This commit is contained in:
@@ -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 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
}
|
||||
@@ -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<Software>? Softwares { get; set; }
|
||||
|
||||
}
|
||||
19
SmallSoftwareProject/SmallSoftwareDatabase/Models/Post.cs
Normal file
19
SmallSoftwareProject/SmallSoftwareDatabase/Models/Post.cs
Normal file
@@ -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; }
|
||||
}
|
||||
22
SmallSoftwareProject/SmallSoftwareDatabase/Models/Request.cs
Normal file
22
SmallSoftwareProject/SmallSoftwareDatabase/Models/Request.cs
Normal file
@@ -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<InstallationRequest>? InstallationRequests { get; set; }
|
||||
}
|
||||
17
SmallSoftwareProject/SmallSoftwareDatabase/Models/Salary.cs
Normal file
17
SmallSoftwareProject/SmallSoftwareDatabase/Models/Salary.cs
Normal file
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -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<SoftwareHistory>? SoftwareHistories { get; set; }
|
||||
|
||||
[ForeignKey("SoftwareId")]
|
||||
public List<InstallationRequest>? InstallationRequests { get; set; }
|
||||
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
24
SmallSoftwareProject/SmallSoftwareDatabase/Models/Worker.cs
Normal file
24
SmallSoftwareProject/SmallSoftwareDatabase/Models/Worker.cs
Normal file
@@ -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<Salary>? Salaries { get; set; }
|
||||
[ForeignKey("WorkerId")]
|
||||
public List<Request>? Requests { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SmallSoftwareContracts\SmallSoftwareContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user