API Traieste

This commit is contained in:
andrei-mihnea-cerbu
2024-04-04 19:21:03 +03:00
parent 22f171b560
commit 1206db9321
104 changed files with 359 additions and 366 deletions
+1 -8
View File
@@ -7,14 +7,7 @@
</PropertyGroup>
<ItemGroup>
<Folder Include="Endpoints\Chat\" />
<Folder Include="Endpoints\MedicalHistory\" />
<Folder Include="Endpoints\Doctors\" />
<Folder Include="Endpoints\Pacients\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
</ItemGroup>
</Project>
@@ -1,8 +0,0 @@
using Core.Entities;
namespace Application.Contracts.Database
{
public interface IConversationRepository
{
}
}
@@ -1,6 +0,0 @@
namespace Application.Contracts.Database
{
public interface IDoctorRepository
{
}
}
@@ -0,0 +1,9 @@
namespace Application.Endpoints
{
public class BaseResponse
{
public bool Success { get; set; }
public string? Message { get; set; }
public object? Data { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace Application.Endpoints.Doctors.Login
{
public class DoctorLoginDTO
{
public string? Email { get; set; }
public string? Password { get; set; }
}
}
@@ -0,0 +1,39 @@
using Application.Services.Database;
namespace Application.Endpoints.Doctors.Login
{
public class DoctorLoginHandler
{
private readonly IDoctorRepository _database;
public DoctorLoginHandler(IDoctorRepository database)
{
_database = database;
}
public async Task<BaseResponse> Handle(DoctorLoginDTO loginDTO)
{
var validation = new DoctorLoginValidation(_database);
var validationResult = await validation.ValidateAsync(loginDTO);
if (!validationResult.IsValid)
{
var errorMessage = validationResult.Errors.FirstOrDefault()?.ErrorMessage;
return new BaseResponse
{
Success = false,
Message = errorMessage,
Data = null
};
}
return new BaseResponse
{
Success = true,
Message = "Authentication successful",
Data = null
};
}
}
}
@@ -0,0 +1,30 @@
using Application.Services.Database;
using FluentValidation;
using System.Threading.Tasks;
namespace Application.Endpoints.Doctors.Login
{
public class DoctorLoginValidation : AbstractValidator<DoctorLoginDTO>
{
private readonly IDoctorRepository _doctorRepository;
public DoctorLoginValidation(IDoctorRepository doctorRepository)
{
_doctorRepository = doctorRepository;
RuleFor(x => x.Email)
.NotEmpty().WithMessage("Email is required.")
.EmailAddress().WithMessage("Invalid email format.")
.MustAsync(BeExistingDoctor).WithMessage("Doctor with this email does not exist.");
RuleFor(x => x.Password)
.NotEmpty().WithMessage("Password is required.")
.MinimumLength(8).WithMessage("Password must be at least 8 characters long.");
}
private async Task<bool> BeExistingDoctor(string email, System.Threading.CancellationToken cancellationToken)
{
return await _doctorRepository.IsDoctorExisting(email);
}
}
}
@@ -0,0 +1,6 @@
namespace Application.Services.Database
{
public interface IConversationRepository
{
}
}
@@ -0,0 +1,7 @@
namespace Application.Services.Database
{
public interface IDoctorRepository
{
Task<bool> IsDoctorExisting(string email);
}
}
@@ -1,4 +1,4 @@
namespace Application.Contracts.Database
namespace Application.Services.Database
{
public interface IMedicalHistoryRepository
{
@@ -1,4 +1,4 @@
namespace Application.Contracts.Database
namespace Application.Services.Database
{
public interface IPacientRepository
{
@@ -8,33 +8,19 @@
".NETCoreApp,Version=v8.0": {
"Application/1.0.0": {
"dependencies": {
"Core": "1.0.0"
"FluentValidation": "11.9.0"
},
"runtime": {
"Application.dll": {}
}
},
"MongoDB.Bson/2.24.0": {
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "5.0.0"
},
"FluentValidation/11.9.0": {
"runtime": {
"lib/netstandard2.1/MongoDB.Bson.dll": {
"assemblyVersion": "2.24.0.0",
"fileVersion": "2.24.0.0"
"lib/net8.0/FluentValidation.dll": {
"assemblyVersion": "11.0.0.0",
"fileVersion": "11.9.0.0"
}
}
},
"System.Memory/4.5.5": {},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {},
"Core/1.0.0": {
"dependencies": {
"MongoDB.Bson": "2.24.0"
},
"runtime": {
"Core.dll": {}
}
}
}
},
@@ -44,31 +30,12 @@
"serviceable": false,
"sha512": ""
},
"MongoDB.Bson/2.24.0": {
"FluentValidation/11.9.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-n8CWaA4iTuoEQYv0+FSKNTX/hJozFQa5EgSILVNPhTGHcrbABHhpVrT1NwRRAAS6sUb8ZyhHmLPBa88LJemptA==",
"path": "mongodb.bson/2.24.0",
"hashPath": "mongodb.bson.2.24.0.nupkg.sha512"
},
"System.Memory/4.5.5": {
"type": "package",
"serviceable": true,
"sha512": "sha512-XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==",
"path": "system.memory/4.5.5",
"hashPath": "system.memory.4.5.5.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==",
"path": "system.runtime.compilerservices.unsafe/5.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512"
},
"Core/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
"sha512": "sha512-VneVlTvwYDkfHV5av3QrQ0amALgrLX6LV94wlYyEsh0B/klJBW7C8y2eAtj5tOZ3jH6CAVpr4s1ZGgew/QWyig==",
"path": "fluentvalidation/11.9.0",
"hashPath": "fluentvalidation.11.9.0.nupkg.sha512"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -24,70 +24,6 @@
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {
"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj": {
"projectPath": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.202/PortableRuntimeIdentifierGraph.json"
}
}
},
"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj",
"projectName": "Core",
"projectPath": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj",
"packagesPath": "C:\\Users\\Andrei Cerbu\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Andrei Cerbu\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
@@ -109,9 +45,9 @@
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"MongoDB.Bson": {
"FluentValidation": {
"target": "Package",
"version": "[2.24.0, )"
"version": "[11.9.0, )"
}
},
"imports": [
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Application")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+041abb59007874167884872bc1a73e753930824b")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+22f171b5600c0f2fcef2f7c927f96f78a59a27a4")]
[assembly: System.Reflection.AssemblyProductAttribute("Application")]
[assembly: System.Reflection.AssemblyTitleAttribute("Application")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
46998ebb81250ee993485416df0909c7143f7792f50aff695b3f5ff97784825e
ef3adc4b3323bf29b92f7848e712ac6c253cbb3465d61f97b1a82fd097090057
@@ -1 +1 @@
0baff5b0c00698cb3bddd23ea11ac67e94bd893e783b855ba6975a15613aa20b
e62e961dcbbbdb298dbb177e9f1605ac5651cf25ce346fbf2dad3942dc43b387
@@ -1,15 +1,12 @@
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.deps.json
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.pdb
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Core.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Core.pdb
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.csproj.AssemblyReference.cache
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.AssemblyInfoInputs.cache
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.AssemblyInfo.cs
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.csproj.CoreCompileInputs.cache
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.sourcelink.json
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Applicat.44B5EDA2.Up2Date
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.deps.json
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\bin\Debug\net8.0\Application.pdb
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.csproj.AssemblyReference.cache
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\refint\Application.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\Application\obj\Debug\net8.0\Application.pdb
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/041abb59007874167884872bc1a73e753930824b/*"}}
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/22f171b5600c0f2fcef2f7c927f96f78a59a27a4/*"}}
+30 -121
View File
@@ -2,144 +2,51 @@
"version": 3,
"targets": {
"net8.0": {
"MongoDB.Bson/2.24.0": {
"type": "package",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "5.0.0"
},
"compile": {
"lib/netstandard2.1/MongoDB.Bson.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/netstandard2.1/MongoDB.Bson.dll": {
"related": ".xml"
}
}
},
"System.Memory/4.5.5": {
"FluentValidation/11.9.0": {
"type": "package",
"compile": {
"ref/netcoreapp2.1/_._": {}
},
"runtime": {
"lib/netcoreapp2.1/_._": {}
}
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"type": "package",
"compile": {
"ref/netstandard2.1/System.Runtime.CompilerServices.Unsafe.dll": {
"lib/net8.0/FluentValidation.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll": {
"lib/net8.0/FluentValidation.dll": {
"related": ".xml"
}
}
},
"Core/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v8.0",
"dependencies": {
"MongoDB.Bson": "2.24.0"
},
"compile": {
"bin/placeholder/Core.dll": {}
},
"runtime": {
"bin/placeholder/Core.dll": {}
}
}
}
},
"libraries": {
"MongoDB.Bson/2.24.0": {
"sha512": "n8CWaA4iTuoEQYv0+FSKNTX/hJozFQa5EgSILVNPhTGHcrbABHhpVrT1NwRRAAS6sUb8ZyhHmLPBa88LJemptA==",
"FluentValidation/11.9.0": {
"sha512": "VneVlTvwYDkfHV5av3QrQ0amALgrLX6LV94wlYyEsh0B/klJBW7C8y2eAtj5tOZ3jH6CAVpr4s1ZGgew/QWyig==",
"type": "package",
"path": "mongodb.bson/2.24.0",
"path": "fluentvalidation/11.9.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"LICENSE.md",
"lib/net472/MongoDB.Bson.dll",
"lib/net472/MongoDB.Bson.xml",
"lib/netstandard2.0/MongoDB.Bson.dll",
"lib/netstandard2.0/MongoDB.Bson.xml",
"lib/netstandard2.1/MongoDB.Bson.dll",
"lib/netstandard2.1/MongoDB.Bson.xml",
"mongodb.bson.2.24.0.nupkg.sha512",
"mongodb.bson.nuspec",
"packageIcon.png"
"README.md",
"fluent-validation-icon.png",
"fluentvalidation.11.9.0.nupkg.sha512",
"fluentvalidation.nuspec",
"lib/net5.0/FluentValidation.dll",
"lib/net5.0/FluentValidation.xml",
"lib/net6.0/FluentValidation.dll",
"lib/net6.0/FluentValidation.xml",
"lib/net7.0/FluentValidation.dll",
"lib/net7.0/FluentValidation.xml",
"lib/net8.0/FluentValidation.dll",
"lib/net8.0/FluentValidation.xml",
"lib/netstandard2.0/FluentValidation.dll",
"lib/netstandard2.0/FluentValidation.xml",
"lib/netstandard2.1/FluentValidation.dll",
"lib/netstandard2.1/FluentValidation.xml"
]
},
"System.Memory/4.5.5": {
"sha512": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==",
"type": "package",
"path": "system.memory/4.5.5",
"files": [
".nupkg.metadata",
".signature.p7s",
"LICENSE.TXT",
"THIRD-PARTY-NOTICES.TXT",
"lib/net461/System.Memory.dll",
"lib/net461/System.Memory.xml",
"lib/netcoreapp2.1/_._",
"lib/netstandard1.1/System.Memory.dll",
"lib/netstandard1.1/System.Memory.xml",
"lib/netstandard2.0/System.Memory.dll",
"lib/netstandard2.0/System.Memory.xml",
"ref/netcoreapp2.1/_._",
"system.memory.4.5.5.nupkg.sha512",
"system.memory.nuspec",
"useSharedDesignerContext.txt",
"version.txt"
]
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"sha512": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==",
"type": "package",
"path": "system.runtime.compilerservices.unsafe/5.0.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"Icon.png",
"LICENSE.TXT",
"THIRD-PARTY-NOTICES.TXT",
"lib/net45/System.Runtime.CompilerServices.Unsafe.dll",
"lib/net45/System.Runtime.CompilerServices.Unsafe.xml",
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll",
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.xml",
"lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll",
"lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.xml",
"lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll",
"lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.xml",
"ref/net461/System.Runtime.CompilerServices.Unsafe.dll",
"ref/net461/System.Runtime.CompilerServices.Unsafe.xml",
"ref/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll",
"ref/netstandard1.0/System.Runtime.CompilerServices.Unsafe.xml",
"ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll",
"ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.xml",
"ref/netstandard2.1/System.Runtime.CompilerServices.Unsafe.dll",
"ref/netstandard2.1/System.Runtime.CompilerServices.Unsafe.xml",
"system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512",
"system.runtime.compilerservices.unsafe.nuspec",
"useSharedDesignerContext.txt",
"version.txt"
]
},
"Core/1.0.0": {
"type": "project",
"path": "../Core/Core.csproj",
"msbuildProject": "../Core/Core.csproj"
}
},
"projectFileDependencyGroups": {
"net8.0": [
"Core >= 1.0.0"
"FluentValidation >= 11.9.0"
]
},
"packageFolders": {
@@ -168,11 +75,7 @@
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {
"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj": {
"projectPath": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Core\\Core.csproj"
}
}
"projectReferences": {}
}
},
"warningProperties": {
@@ -189,6 +92,12 @@
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"FluentValidation": {
"target": "Package",
"version": "[11.9.0, )"
}
},
"imports": [
"net461",
"net462",
+2 -4
View File
@@ -1,12 +1,10 @@
{
"version": 2,
"dgSpecHash": "/Nvfi+nbQtMHVdhP73amZPlhgGbKCShznaf20Qy8tcaEaX5iC3bWAxzDzWwQr6A7MjYisEXLzsQl9SC0GV5JcA==",
"dgSpecHash": "kDc083K6qMrDLCVeOJ9DuILYrf/AP3owIBIRxiyDRQz9yRIDKVbxrCbVBAIi79Pb4cXkOYdSYtBCvpHN76uuPw==",
"success": true,
"projectFilePath": "C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\backend\\Application\\Application.csproj",
"expectedPackageFiles": [
"C:\\Users\\Andrei Cerbu\\.nuget\\packages\\mongodb.bson\\2.24.0\\mongodb.bson.2.24.0.nupkg.sha512",
"C:\\Users\\Andrei Cerbu\\.nuget\\packages\\system.memory\\4.5.5\\system.memory.4.5.5.nupkg.sha512",
"C:\\Users\\Andrei Cerbu\\.nuget\\packages\\system.runtime.compilerservices.unsafe\\5.0.0\\system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512"
"C:\\Users\\Andrei Cerbu\\.nuget\\packages\\fluentvalidation\\11.9.0\\fluentvalidation.11.9.0.nupkg.sha512"
],
"logs": []
}