Compare commits

...

26 Commits
main ... Models

Author SHA1 Message Date
Lazypr0ger
50fabdaf55 Package for BusinessLogic and Storage Contracts: created 2025-04-24 13:07:09 +04:00
Lazypr0ger
e34abad173 tests Datamodel: deleted #2 (past true conflict) 2025-04-24 12:54:47 +04:00
Lazypr0ger
9a6963d2c5 Deleted tests. Start separate development 2025-04-24 12:53:52 +04:00
85c3a97d23 workertest part 1 2025-04-12 22:46:17 +04:00
b44784854a да емае 2025-04-12 21:44:09 +04:00
30852efca6 ЕЩЁРАЗ 2025-04-12 21:42:54 +04:00
9132f6d7c3 TESTS 2025-04-12 21:18:23 +04:00
651f3d5564 fix 2025-04-12 21:15:33 +04:00
1ec2a956d3 EducationDataModel tests 2025-04-12 21:12:21 +04:00
142d9d2bf8 Tests 1 2025-04-12 21:10:38 +04:00
Lazypr0ger
e66849ac08 Correcting Validation and class datamodels 2025-04-12 17:33:51 +04:00
Lazypr0ger
046921f18d students and payment validation 2025-04-12 17:07:29 +04:00
84b2f754d1 Project Tests 2025-04-12 16:31:46 +04:00
Lazypr0ger
d9123e9f2c User Validation complited 2025-04-12 16:23:24 +04:00
38ecc483c2 data modelky 2025-04-12 16:24:04 +04:00
Lazypr0ger
6156a55dd9 Validation classes complited 2025-04-12 15:52:43 +04:00
0688934faf TeacherPositionType 2 2025-04-12 15:50:57 +04:00
Lazypr0ger
d80e031d74 student Data Model and groop and faculty type complited 2025-04-12 15:45:13 +04:00
1925bb4fcc Teacher, Education 2025-04-12 15:45:43 +04:00
89e4449b96 TeacherPositionType 2025-04-12 15:29:20 +04:00
3a6f28ecfb TeacherDataModel 2025-04-12 15:19:18 +04:00
Lazypr0ger
f3cf508702 UserDataModel and Enums Role 2025-04-12 15:16:18 +04:00
Lazypr0ger
134f277016 FirstModels 2025-04-12 14:58:51 +04:00
Lazypr0ger
5bbf76d13b Qest 2025-04-12 14:55:34 +04:00
Lazypr0ger
0279d05a36 Refactoring 2025-04-12 14:42:45 +04:00
Lazypr0ger
d7109524d1 StartDevelopment 2025-04-12 14:22:44 +04:00
19 changed files with 569 additions and 0 deletions

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35806.99
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityAllExpelled_Models", "UniversityAllExpelled_Models\UniversityAllExpelled_Models.csproj", "{B2364D1E-38B8-4DF7-90DB-49F8463A1B40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityAllExpelled_Tests", "UniversityAllExpelled_Tests\UniversityAllExpelled_Tests.csproj", "{E3D5BB9F-436E-44FC-AB2C-5D643628BAD2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B2364D1E-38B8-4DF7-90DB-49F8463A1B40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2364D1E-38B8-4DF7-90DB-49F8463A1B40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2364D1E-38B8-4DF7-90DB-49F8463A1B40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2364D1E-38B8-4DF7-90DB-49F8463A1B40}.Release|Any CPU.Build.0 = Release|Any CPU
{E3D5BB9F-436E-44FC-AB2C-5D643628BAD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3D5BB9F-436E-44FC-AB2C-5D643628BAD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3D5BB9F-436E-44FC-AB2C-5D643628BAD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3D5BB9F-436E-44FC-AB2C-5D643628BAD2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {256411BF-AC51-436B-B254-59E602A9AE79}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,53 @@

using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Client;
public class PaymentDataModel(string id, string studentId, double paidAmount, double arrears, bool paidOf) : IValidation
{
public string Id { get; private set; } = id;
public string StudentsId { get; private set; } = studentId;
public double PaidAmount { get; private set; } = paidAmount;
public double Arrears { get; private set; } = arrears;
public bool PaidOf { get; private set; } = paidOf;
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 valid GUID.");
}
if (StudentsId.IsEmpty())
{
throw new ValidationException("Field StudentsId is empty.");
}
if (!StudentsId.IsGuid())
{
throw new ValidationException("The value in the field StudentsId is not a valid GUID.");
}
if (PaidAmount < 0)
{
throw new ValidationException("Field PaidAmount cannot be negative.");
}
if (Arrears < 0)
{
throw new ValidationException("Field Arrears cannot be negative.");
}
if (PaidOf && Arrears != 0)
{
throw new ValidationException("If PaidOf is true, Arrears must be 0.");
}
}
}

View File

@@ -0,0 +1,30 @@
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Client;
public class PaymentLessonDataModel(string paymentId, string lessonId) : IValidation
{
public string PaymentId { get; private set; }
public string LessonId { get; private set; }
public void Validate()
{
if (PaymentId.IsEmpty())
{
throw new ValidationException("Field PaymentId is empty.");
}
if (!PaymentId.IsGuid())
{
throw new ValidationException("The value in the field PaymentId is not a valid GUID.");
}
if (LessonId.IsEmpty())
{
throw new ValidationException("Field LessonId is empty.");
}
if (!LessonId.IsGuid())
{
throw new ValidationException("The value in the field LessonId is not a valid GUID.");
}
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityAllExpelled_Models.Enums;
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Client;
public class StudentDataModel(string id, string userId, FacultyType faculty, GroopType groop, int course) : IValidation
{
public string Id { get; private set; } = id;
public string UserId { get; private set; } = userId;
public FacultyType Faculty { get; private set; } = faculty;
public GroopType Groop { get; private set; } = groop;
public int Course { get; private set; } = course;
public void Validate()
{
if (Id.IsEmpty())
{
throw new ValidationException("Field Id is empty.");
}
if (!Id.IsGuid())
{
throw new ValidationException("The value in field Id is not a valid GUID.");
}
if (UserId.IsEmpty())
{
throw new ValidationException("Field UserId is empty.");
}
if (!UserId.IsGuid())
{
throw new ValidationException("The value in field UserId is not a valid GUID.");
}
if (Faculty == FacultyType.None)
{
throw new ValidationException("Faculty must be specified (cannot be None).");
}
if (Groop == GroopType.None)
{
throw new ValidationException("Group must be specified (cannot be None).");
}
// Проверка Course (должен быть от 1 до 6)
if (Course < 1 || Course > 6)
{
throw new ValidationException("Course must be between 1 and 6.");
}
}
}

View File

@@ -0,0 +1,50 @@

using System;
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Worker;
public class LessonDataModel(string id, string name, double price, DateTime startDate, DateTime endDate, string studentId, string salaryId,bool isActive) : IValidation
{
public string Id { get;private set; } = id;
public string Name { get; private set; } = name;
public double Price { get; private set; } = price;
public DateTime StartDate { get; private set; } = startDate;
public DateTime EndDate { get; private set; } = endDate;
public string StudentId { get; private set; } = studentId;
public string SalaryId { get; private set; } = salaryId;
public bool IsActive { get; private set; } = isActive;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Lesson ID cannot be empty");
if (!Id.IsGuid())
throw new ValidationException("Lesson ID must be in valid GUID format");
if (Name.IsEmpty())
throw new ValidationException("Lesson name cannot be empty");
if (Price <= 0)
throw new ValidationException("Total hours must be greater than zero");
if (StartDate.Date > EndDate.Date)
throw new ValidationException("Start date cannot be later than end date");
if (StudentId.IsEmpty())
throw new ValidationException("LessonID cannot be empty");
if (!StudentId.IsGuid())
throw new ValidationException("Student record ID must be in valid GUID format");
if (SalaryId.IsEmpty())
throw new ValidationException("Salary ID must be a valid GUID when provided");
if (!SalaryId.IsGuid())
throw new ValidationException("Salary record ID must be in valid GUID format");
}
}

View File

@@ -0,0 +1,81 @@
using System.Text.RegularExpressions;
using System.Xml.Linq;
using UniversityAllExpelled_Models.Enums;
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels;
public class UserDataModel(string id, string login, string password, SystemRoleType role,
string fio, DateTime birthdate,string phoneNomber, string email, bool isDeleted) : IValidation
{
public string Id { get; private set; } = id;
public string Login { get; private set; } = login;
public string Password { get; private set; } = password;
public SystemRoleType Role { get; private set; } = role;
public string FIO { get; private set; } = fio;
public DateTime BirthDate { get; private set; } = birthdate;
public string PhoneNomber { get; private set; } = phoneNomber;
public string Email { get; private set; } = email;
public bool IsDeleted { get; private set; } = isDeleted;
public void Validate()
{
if (Id.IsEmpty())
{
throw new ValidationException("Filed Id is empty");
}
if (!Id.IsGuid())
{
throw new ValidationException("The value in the filed Id is not a unique identifier");
}
if (Login.IsEmpty() || Password == null)
{
throw new ValidationException("Filed Login is empty or null");
}
if(Password.IsEmpty() || Password == null)
{
throw new ValidationException("Filed Password is empty or null");
}
if (!Regex.IsMatch(Password, @"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+{}\[\]:;'"",.<>?\/\\|`~\-=]).{8,}$"))
{
throw new ValidationException("The password field was entered incorrectly. \r\n" +
"Your password must contain at least one lowercase letter a-z, one uppercase letter A-Z,\n" +
" one digit 0-9 and one special character!@#$%^&*()_+{}\\[\\]:;'\"\",.<>?\\/\\\\|`~\\-= ");
}
if(Role == SystemRoleType.None)
{
throw new ValidationException("The Role field must not be None Role ");
}
if (FIO.IsEmpty() || FIO == null)
{
throw new ValidationException("Filed FIO is empty or null");
}
if(BirthDate.Date < DateTime.Now.AddYears(-16))
{
throw new ValidationException("The Birthday field was entered incorrectly");
}
if (!Regex.IsMatch(PhoneNomber, @"^(\+7|8)(-?\d{3}-?\d{3}-?\d{2}-?\d{2}|-?\d{10})$"))
{
throw new ValidationException("The PhoneNomber field was entered incorrectly.");
}
if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9._%+-]+@(?:yandex\.[a-z]{2,}|mail\.ru|inbox\.ru|list\.ru|bk\.ru|gmail\.com)$"))
{
throw new ValidationException("The Email field was entered incorrectly.");
}
}
}

View File

@@ -0,0 +1,49 @@
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Infrostructure;
public class EducationDataModel : IValidation
{
public string Id { get; set; }
public string TeacherId { get; set; }
public float Amount { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public bool Active { get; set; }
public EducationDataModel(string id, string teacherId, float amount, DateTime startDate, DateTime endDate, bool active)
{
Id = id;
TeacherId = teacherId;
Amount = amount;
StartDate = startDate;
EndDate = endDate;
Active = active;
}
public void Validate()
{
if (string.IsNullOrEmpty(Id))
throw new ValidationException("Education record ID cannot be empty");
if (!Guid.TryParse(Id, out _))
throw new ValidationException("Education record ID must be in valid GUID format");
if (string.IsNullOrEmpty(TeacherId))
throw new ValidationException("Teacher ID cannot be empty");
if (!Guid.TryParse(TeacherId, out _))
throw new ValidationException("Teacher ID must be in valid GUID format");
if (Amount <= 0)
throw new ValidationException("Education amount must be greater than zero");
if (StartDate == default)
throw new ValidationException("Start date must be specified");
if (EndDate == default)
throw new ValidationException("End date must be specified");
if (StartDate > EndDate)
throw new ValidationException("Start date cannot be after end date");
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.ComponentModel.DataAnnotations;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Worker;
public class EducationLessonsDataModel(string educationId, string lessonsId) : IValidation
{
public string EducationId { get; private set; } = educationId;
public string LessonsId { get; private set; } = lessonsId;
public void Validate()
{
if (EducationId.IsEmpty())
throw new ValidationException("Education ID cannot be empty");
if (!EducationId.IsGuid())
throw new ValidationException("Education ID must be in valid GUID format");
if (LessonsId.IsEmpty())
throw new ValidationException("Lesson ID cannot be empty");
if (!LessonsId.IsGuid())
throw new ValidationException("Lesson ID must be in valid GUID format");
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.ComponentModel.DataAnnotations;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Worker;
public class SalaryDataModel(string id, double count, DateTime date) : IValidation
{
public string Id { get; private set; } = id;
public double Count { get; private set; } = count;
public DateTime Date { get; private set; } = date;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Salary record ID cannot be empty");
if (!Id.IsGuid())
throw new ValidationException("Salary record ID must be in valid GUID format");
if (Count <= 0)
throw new ValidationException("Salary amount must be greater than zero");
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityAllExpelled_Models.Enums;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Worker;
public class TeacherDataModel(string id, TeacherPositionType position, string userid) : IValidation
{
public string Id { get; private set; } = id;
public string Userid { get; private set; } = userid;
public TeacherPositionType Position { get; set; } = position;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Teacher ID cannot be empty");
if (!Id.IsGuid())
throw new ValidationException("Teacher ID must be a valid GUID");
if (Userid.IsEmpty())
throw new ValidationException("User ID cannot be empty");
if (!Userid.IsGuid())
throw new ValidationException("User ID must be a valid GUID");
if (Position == TeacherPositionType.None)
throw new ValidationException("Teacher position must be specified");
}
}

View File

@@ -0,0 +1,9 @@

namespace UniversityAllExpelled_Models.Enums;
public enum FacultyType
{
None = 0,
fist = 1,
enginers = 2
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityAllExpelled_Models.Enums;
public enum GroopType
{
None = 0,
//fist
ISEbd21 = 1,
ISEbd22 = 2,
Pibd21 = 3,
Pibd22 = 4
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityAllExpelled_Models.Enums;
public enum SystemRoleType
{
None = 0,
student = 1,
teacher = 2
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityAllExpelled_Models.Enums;
public enum TeacherPositionType
{
None = 0,
dekan = 1,
Seniorlecturer = 2,
Juniorteacher = 3
}

View File

@@ -0,0 +1,7 @@

namespace UniversityAllExpelled_Models.Exceptions;
public class ValidationException(string message) : Exception(message)
{
}

View File

@@ -0,0 +1,15 @@

namespace UniversityAllExpelled_Models.Extensions;
public static class StringExtensions
{
public static bool IsEmpty(this string str)
{
return string.IsNullOrWhiteSpace(str);
}
public static bool IsGuid(this string str)
{
return Guid.TryParse(str, out _);
}
}

View File

@@ -0,0 +1,7 @@

namespace UniversityAllExpelled_Models.Infrostructure;
public interface IValidation
{
void Validate();
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="BusinessLogicContracts\" />
<Folder Include="StorageContracts\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UniversityAllExpelled_Models\UniversityAllExpelled_Models.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>
</Project>