diff --git a/DocuMed.Api/AppSettings/Production/appsettings.Production.json b/DocuMed.Api/AppSettings/Production/appsettings.Production.json
index d2e5976..9f11b6c 100644
--- a/DocuMed.Api/AppSettings/Production/appsettings.Production.json
+++ b/DocuMed.Api/AppSettings/Production/appsettings.Production.json
@@ -13,7 +13,7 @@
},
"SiteSettings": {
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
- "BaseUrl": "http://localhost:32769",
+ "BaseUrl": "http://localhost:32780",
"UserSetting": {
"Username": "Root",
"Email": "info@brizco.io",
diff --git a/DocuMed.Api/Controllers/PatientController.cs b/DocuMed.Api/Controllers/PatientController.cs
index 8f9166e..a94d046 100644
--- a/DocuMed.Api/Controllers/PatientController.cs
+++ b/DocuMed.Api/Controllers/PatientController.cs
@@ -1,4 +1,8 @@
-namespace DocuMed.Api.Controllers;
+using DocuMed.Domain.CommandQueries.Queries;
+using DocuMed.Domain.Models;
+using MediatR;
+
+namespace DocuMed.Api.Controllers;
public class PatientController : ICarterModule
{
diff --git a/DocuMed.Api/DocuMed.Api.csproj b/DocuMed.Api/DocuMed.Api.csproj
index 0b5151c..9aacdcc 100644
--- a/DocuMed.Api/DocuMed.Api.csproj
+++ b/DocuMed.Api/DocuMed.Api.csproj
@@ -1,112 +1,111 @@
-
- net9.0
- enable
- enable
- Linux
- ..\docker-compose.dcproj
- 1.3.2.1
- 1.3.2.1
-
+
+ net8.0
+ enable
+ enable
+ Linux
+ ..\docker-compose.dcproj
+ 1.3.2.1
+ 1.3.2.1
+
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/DocuMed.Api/Program.cs b/DocuMed.Api/Program.cs
index e1870af..bb269f6 100644
--- a/DocuMed.Api/Program.cs
+++ b/DocuMed.Api/Program.cs
@@ -1,4 +1,6 @@
using DocuMed.Api.WebFramework.MiddleWares;
+using DocuMed.Repository.Behaviors;
+using MediatR.Extensions.Autofac.DependencyInjection.Builder;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
@@ -65,6 +67,24 @@ builder.Host.ConfigureContainer(builder =>
.AssignableTo()
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
+
+ builder.RegisterMediatR(MediatRConfigurationBuilder
+ .Create(typeof(RepositoryConfig).Assembly)
+ .WithCustomPipelineBehavior(typeof(ValidationBehavior<,>))
+ .WithAllOpenGenericHandlerTypesRegistered()
+ .Build());
+
+ builder.RegisterMediatR(MediatRConfigurationBuilder
+ .Create(typeof(CoreConfig).Assembly)
+ .WithCustomPipelineBehavior(typeof(ValidationBehavior<,>))
+ .WithAllOpenGenericHandlerTypesRegistered()
+ .Build());
+
+ builder.RegisterMediatR(MediatRConfigurationBuilder
+ .Create(typeof(DomainConfig).Assembly)
+ .WithCustomPipelineBehavior(typeof(ValidationBehavior<,>))
+ .WithAllOpenGenericHandlerTypesRegistered()
+ .Build());
});
var app = builder.Build();
diff --git a/DocuMed.Api/Properties/launchSettings.json b/DocuMed.Api/Properties/launchSettings.json
index d544ef5..d908901 100644
--- a/DocuMed.Api/Properties/launchSettings.json
+++ b/DocuMed.Api/Properties/launchSettings.json
@@ -20,7 +20,7 @@
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
- "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
+ "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger/v1",
"environmentVariables": {
"ASPNETCORE_URLS": "http://+:80"
},
diff --git a/DocuMed.Common/DocuMed.Common.csproj b/DocuMed.Common/DocuMed.Common.csproj
index 0826a13..a890827 100644
--- a/DocuMed.Common/DocuMed.Common.csproj
+++ b/DocuMed.Common/DocuMed.Common.csproj
@@ -1,7 +1,7 @@
-
- net9.0
+
+ net8.0
10
enable
@@ -24,7 +24,7 @@
-
+
@@ -33,4 +33,4 @@
-
+
\ No newline at end of file
diff --git a/DocuMed.Common/Models/Exception/ValidationException.cs b/DocuMed.Common/Models/Exception/ValidationException.cs
new file mode 100644
index 0000000..7286d7b
--- /dev/null
+++ b/DocuMed.Common/Models/Exception/ValidationException.cs
@@ -0,0 +1,20 @@
+namespace DocuMed.Common.Models.Exception;
+
+public class ValidationException : System.Exception
+{
+ public ValidationException() : base("Validation has been failed")
+ {
+
+ }
+
+ public ValidationException(params ValidationError[] validationErrors) : base($"{string.Join(",", validationErrors.Select(v => v.ErrorMessage))}")
+ {
+
+ }
+
+ public ValidationException(List validationErrors) : base($"{string.Join(",", validationErrors.Select(v => v.ErrorMessage))}")
+ {
+
+ }
+}
+public sealed record ValidationError(string PropertyName, string ErrorMessage);
\ No newline at end of file
diff --git a/DocuMed.Core/CoreServices/AccountService.cs b/DocuMed.Core/CoreServices/AccountService.cs
index 2bf9f94..a4cacdb 100644
--- a/DocuMed.Core/CoreServices/AccountService.cs
+++ b/DocuMed.Core/CoreServices/AccountService.cs
@@ -114,7 +114,9 @@ public class AccountService(
.FirstOrDefaultAsync(f => f.UserId == user.Id, cancellationToken);
if (student == null)
{
- student = Student.Create(requestDto.UniversityId,requestDto.SectionId,user.Id);
+ student = Student.Create(requestDto.UniversityId, user.Id);
+ if (requestDto.SectionId != default)
+ student.SetSection(requestDto.SectionId);
repositoryWrapper.SetRepository().Add(student);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
}
@@ -126,7 +128,7 @@ public class AccountService(
return await CompleteLogin(user, cancellationToken);
}
- private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken)
+ private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken)
{
var token = await jwtService.Generate(user);
var student = await repositoryWrapper.SetRepository().TableNoTracking
diff --git a/DocuMed.Core/DocuMed.Core.csproj b/DocuMed.Core/DocuMed.Core.csproj
index f00d758..ba3a179 100644
--- a/DocuMed.Core/DocuMed.Core.csproj
+++ b/DocuMed.Core/DocuMed.Core.csproj
@@ -1,10 +1,10 @@
-
- net9.0
- enable
- enable
-
+
+ net8.0
+ enable
+ enable
+
@@ -12,47 +12,47 @@
-
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DocuMed.Domain/DocuMed.Domain.csproj b/DocuMed.Domain/DocuMed.Domain.csproj
index 82f2233..c16dd0e 100644
--- a/DocuMed.Domain/DocuMed.Domain.csproj
+++ b/DocuMed.Domain/DocuMed.Domain.csproj
@@ -1,22 +1,22 @@
- net9.0
- enable
- enable
-
+ net8.0
+ enable
+ enable
+
-
+