From ed0ed98592a43bfd4fbbc895335de441963eda8d Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Sat, 28 Oct 2023 23:04:24 +0500 Subject: [PATCH 01/10] Cleaned code --- MedX.sln | 17 ++++++++++--- src/MedX.Data/Contexts/AppDbContext.cs | 8 +++--- .../Migrations/20231001081343_InitialMig.cs | 3 +-- src/MedX.Data/Repositories/Repository.cs | 4 +-- .../Entities/Administrators/Adminstrator.cs | 4 +-- src/MedX.Domain/Entities/Patients/Patient.cs | 6 ++--- src/MedX.Domain/Entities/Rooms/Room.cs | 3 ++- src/MedX.Domain/Enums/Gender.cs | 2 +- src/MedX.Domain/Enums/TypeOfPayment.cs | 2 +- .../DTOs/AffairItems/AffairItemCreationDto.cs | 2 +- .../DTOs/Appointments/AppointmentResultDto.cs | 1 - .../DTOs/Assets/AssetCreationDto.cs | 5 ---- .../DTOs/Doctors/DoctorResultDto.cs | 1 - .../MedicalRecordCreationDto.cs | 4 +-- .../DTOs/Payments/PaymentResultDto.cs | 1 - .../DTOs/Treatments/TreatmentCreationDto.cs | 4 +-- .../Exceptions/CustomException.cs | 4 +-- .../Helpers/CheckPhoneAttribute.cs | 4 +-- src/MedX.Service/Interfaces/IAffairService.cs | 1 - .../Interfaces/IMedicalRecordService.cs | 1 - .../Interfaces/IPaymentService.cs | 1 - src/MedX.Service/Mappers/MappingProfile.cs | 24 +++++++++--------- src/MedX.Service/Services/AdminService.cs | 18 ++++++------- .../Services/AffairItemService.cs | 14 +++++------ src/MedX.Service/Services/AffairService.cs | 6 ++--- .../Services/AppointmentService.cs | 8 +++--- src/MedX.Service/Services/AssetService.cs | 8 +++--- src/MedX.Service/Services/AuthService.cs | 14 +++++------ src/MedX.Service/Services/CashDeskService.cs | 2 -- src/MedX.Service/Services/DoctorService.cs | 12 ++++----- .../Services/MedicalRecordService.cs | 9 +++---- src/MedX.Service/Services/PatientService.cs | 8 +++--- src/MedX.Service/Services/PaymentService.cs | 6 ++--- src/MedX.Service/Services/RoomService.cs | 8 +++--- src/MedX.Service/Services/TreatmentService.cs | 14 +++++------ .../Validators/PhoneNumberValidator.cs | 14 +++++++++++ src/MedX.WebApi/.config/dotnet-tools.json | 12 +++++++++ .../Controllers/AdminsController.cs | 6 ++--- .../Controllers/AffairItemsController.cs | 14 +++++------ .../Controllers/AffairsController.cs | 4 +-- .../Controllers/AppointmentsController.cs | 8 +++--- src/MedX.WebApi/Controllers/BaseController.cs | 3 +-- .../Controllers/DoctorsController.cs | 4 +-- .../Controllers/MedicalRecordsControllers.cs | 1 - .../Extensions/ServiceCollection.cs | 6 ++--- src/MedX.WebApi/Program.cs | 2 +- test/MedX.Tests/GlobalUsings.cs | 1 + test/MedX.Tests/MedX.Tests.csproj | 25 +++++++++++++++++++ .../PhoneNumberValidatorTest.cs | 11 ++++++++ 49 files changed, 196 insertions(+), 144 deletions(-) create mode 100644 src/MedX.Service/Validators/PhoneNumberValidator.cs create mode 100644 src/MedX.WebApi/.config/dotnet-tools.json create mode 100644 test/MedX.Tests/GlobalUsings.cs create mode 100644 test/MedX.Tests/MedX.Tests.csproj create mode 100644 test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs diff --git a/MedX.sln b/MedX.sln index 1bea583..14980be 100644 --- a/MedX.sln +++ b/MedX.sln @@ -5,13 +5,17 @@ VisualStudioVersion = 17.7.34003.232 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{681E78B2-785A-4771-B7B9-9BC2D72A8856}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedX.WebApi", "src\MedX.WebApi\MedX.WebApi.csproj", "{2D234F20-3EA8-4541-8772-BE8B66D1D648}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MedX.WebApi", "src\MedX.WebApi\MedX.WebApi.csproj", "{2D234F20-3EA8-4541-8772-BE8B66D1D648}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedX.Data", "src\MedX.Data\MedX.Data.csproj", "{2A5CFE2B-E743-4F9C-8BFF-416391A2F023}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MedX.Data", "src\MedX.Data\MedX.Data.csproj", "{2A5CFE2B-E743-4F9C-8BFF-416391A2F023}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedX.Service", "src\MedX.Service\MedX.Service.csproj", "{FF5939B4-5925-40E4-8FB1-C40A6967FB9D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MedX.Service", "src\MedX.Service\MedX.Service.csproj", "{FF5939B4-5925-40E4-8FB1-C40A6967FB9D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedX.Domain", "src\MedX.Domain\MedX.Domain.csproj", "{00ED443E-1ACF-4F62-A9AB-D976AE39327C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MedX.Domain", "src\MedX.Domain\MedX.Domain.csproj", "{00ED443E-1ACF-4F62-A9AB-D976AE39327C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D94B18A3-92E9-4A34-945A-D262BBEF8229}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedX.Tests", "test\MedX.Tests\MedX.Tests.csproj", "{522EC1FF-C5F8-4136-A846-CD3E76B30A88}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -35,6 +39,10 @@ Global {00ED443E-1ACF-4F62-A9AB-D976AE39327C}.Debug|Any CPU.Build.0 = Debug|Any CPU {00ED443E-1ACF-4F62-A9AB-D976AE39327C}.Release|Any CPU.ActiveCfg = Release|Any CPU {00ED443E-1ACF-4F62-A9AB-D976AE39327C}.Release|Any CPU.Build.0 = Release|Any CPU + {522EC1FF-C5F8-4136-A846-CD3E76B30A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {522EC1FF-C5F8-4136-A846-CD3E76B30A88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {522EC1FF-C5F8-4136-A846-CD3E76B30A88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {522EC1FF-C5F8-4136-A846-CD3E76B30A88}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -44,6 +52,7 @@ Global {2A5CFE2B-E743-4F9C-8BFF-416391A2F023} = {681E78B2-785A-4771-B7B9-9BC2D72A8856} {FF5939B4-5925-40E4-8FB1-C40A6967FB9D} = {681E78B2-785A-4771-B7B9-9BC2D72A8856} {00ED443E-1ACF-4F62-A9AB-D976AE39327C} = {681E78B2-785A-4771-B7B9-9BC2D72A8856} + {522EC1FF-C5F8-4136-A846-CD3E76B30A88} = {D94B18A3-92E9-4A34-945A-D262BBEF8229} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1FC32A05-93D1-4963-9B39-FDAB64CD0452} diff --git a/src/MedX.Data/Contexts/AppDbContext.cs b/src/MedX.Data/Contexts/AppDbContext.cs index 90f7586..35a8aee 100644 --- a/src/MedX.Data/Contexts/AppDbContext.cs +++ b/src/MedX.Data/Contexts/AppDbContext.cs @@ -1,16 +1,16 @@ using MedX.Domain.Entities; -using MedX.Domain.Entities.Services; -using Microsoft.EntityFrameworkCore; -using MedX.Domain.Entities.Appointments; using MedX.Domain.Entities.Administrators; +using MedX.Domain.Entities.Appointments; using MedX.Domain.Entities.MedicalRecords; +using MedX.Domain.Entities.Services; +using Microsoft.EntityFrameworkCore; namespace MedX.Data.Contexts; public class AppDbContext : DbContext { public AppDbContext(DbContextOptions options) : base(options) - { + { } public DbSet Rooms { get; set; } diff --git a/src/MedX.Data/Migrations/20231001081343_InitialMig.cs b/src/MedX.Data/Migrations/20231001081343_InitialMig.cs index aac25e4..8926c14 100644 --- a/src/MedX.Data/Migrations/20231001081343_InitialMig.cs +++ b/src/MedX.Data/Migrations/20231001081343_InitialMig.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/MedX.Data/Repositories/Repository.cs b/src/MedX.Data/Repositories/Repository.cs index e6ac7f8..2fe177f 100644 --- a/src/MedX.Data/Repositories/Repository.cs +++ b/src/MedX.Data/Repositories/Repository.cs @@ -1,8 +1,8 @@ using MedX.Data.Contexts; -using MedX.Domain.Commons; using MedX.Data.IRepositories; -using System.Linq.Expressions; +using MedX.Domain.Commons; using Microsoft.EntityFrameworkCore; +using System.Linq.Expressions; namespace MedX.Data.Repositories; diff --git a/src/MedX.Domain/Entities/Administrators/Adminstrator.cs b/src/MedX.Domain/Entities/Administrators/Adminstrator.cs index fbedaab..8d0307b 100644 --- a/src/MedX.Domain/Entities/Administrators/Adminstrator.cs +++ b/src/MedX.Domain/Entities/Administrators/Adminstrator.cs @@ -1,6 +1,6 @@ -using MedX.Domain.Enums; -using MedX.Domain.Commons; +using MedX.Domain.Commons; using MedX.Domain.Entities.Assets; +using MedX.Domain.Enums; namespace MedX.Domain.Entities.Administrators; diff --git a/src/MedX.Domain/Entities/Patients/Patient.cs b/src/MedX.Domain/Entities/Patients/Patient.cs index 7c28269..c37d21e 100644 --- a/src/MedX.Domain/Entities/Patients/Patient.cs +++ b/src/MedX.Domain/Entities/Patients/Patient.cs @@ -1,8 +1,8 @@ -using MedX.Domain.Enums; -using MedX.Domain.Commons; -using MedX.Domain.Entities.Services; +using MedX.Domain.Commons; using MedX.Domain.Entities.Appointments; using MedX.Domain.Entities.MedicalRecords; +using MedX.Domain.Entities.Services; +using MedX.Domain.Enums; namespace MedX.Domain.Entities; diff --git a/src/MedX.Domain/Entities/Rooms/Room.cs b/src/MedX.Domain/Entities/Rooms/Room.cs index e69d255..7d5b2b9 100644 --- a/src/MedX.Domain/Entities/Rooms/Room.cs +++ b/src/MedX.Domain/Entities/Rooms/Room.cs @@ -9,7 +9,8 @@ public class Room : Auditable private int busy; public int Number { get; set; } public int Quantity { get; set; } - public int Busy { + public int Busy + { get => busy; set { diff --git a/src/MedX.Domain/Enums/Gender.cs b/src/MedX.Domain/Enums/Gender.cs index ff37ddf..a78c5aa 100644 --- a/src/MedX.Domain/Enums/Gender.cs +++ b/src/MedX.Domain/Enums/Gender.cs @@ -2,6 +2,6 @@ public enum Gender { - Male = 1, + Male = 1, Female } diff --git a/src/MedX.Domain/Enums/TypeOfPayment.cs b/src/MedX.Domain/Enums/TypeOfPayment.cs index e1002f4..9a8d8c6 100644 --- a/src/MedX.Domain/Enums/TypeOfPayment.cs +++ b/src/MedX.Domain/Enums/TypeOfPayment.cs @@ -3,5 +3,5 @@ public enum TypeOfPayment { Cash, - Card + Card } diff --git a/src/MedX.Service/DTOs/AffairItems/AffairItemCreationDto.cs b/src/MedX.Service/DTOs/AffairItems/AffairItemCreationDto.cs index 9a2ca0c..cb43122 100644 --- a/src/MedX.Service/DTOs/AffairItems/AffairItemCreationDto.cs +++ b/src/MedX.Service/DTOs/AffairItems/AffairItemCreationDto.cs @@ -5,5 +5,5 @@ namespace MedX.Service.DTOs.ServiceItems; public class AffairItemCreationDto { public long PatientId { get; set; } - public ICollection AffairItems { get; set;} + public ICollection AffairItems { get; set; } } \ No newline at end of file diff --git a/src/MedX.Service/DTOs/Appointments/AppointmentResultDto.cs b/src/MedX.Service/DTOs/Appointments/AppointmentResultDto.cs index 9c97fbd..fc4b43a 100644 --- a/src/MedX.Service/DTOs/Appointments/AppointmentResultDto.cs +++ b/src/MedX.Service/DTOs/Appointments/AppointmentResultDto.cs @@ -1,6 +1,5 @@ using MedX.Service.DTOs.Doctors; using MedX.Service.DTOs.Patients; -using MedX.Service.DTOs.Payments; namespace MedX.Service.DTOs.Appointments; diff --git a/src/MedX.Service/DTOs/Assets/AssetCreationDto.cs b/src/MedX.Service/DTOs/Assets/AssetCreationDto.cs index 03f229a..99fab78 100644 --- a/src/MedX.Service/DTOs/Assets/AssetCreationDto.cs +++ b/src/MedX.Service/DTOs/Assets/AssetCreationDto.cs @@ -1,9 +1,4 @@ using Microsoft.AspNetCore.Http; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MedX.Service.DTOs.Assets; diff --git a/src/MedX.Service/DTOs/Doctors/DoctorResultDto.cs b/src/MedX.Service/DTOs/Doctors/DoctorResultDto.cs index 2314888..6a576f3 100644 --- a/src/MedX.Service/DTOs/Doctors/DoctorResultDto.cs +++ b/src/MedX.Service/DTOs/Doctors/DoctorResultDto.cs @@ -1,5 +1,4 @@ using MedX.Service.DTOs.Assets; -using MedX.Service.DTOs.Rooms; namespace MedX.Service.DTOs.Doctors; diff --git a/src/MedX.Service/DTOs/MedicalRecords/MedicalRecordCreationDto.cs b/src/MedX.Service/DTOs/MedicalRecords/MedicalRecordCreationDto.cs index ece2709..093bb39 100644 --- a/src/MedX.Service/DTOs/MedicalRecords/MedicalRecordCreationDto.cs +++ b/src/MedX.Service/DTOs/MedicalRecords/MedicalRecordCreationDto.cs @@ -1,6 +1,4 @@ -using MedX.Domain.Entities; - -namespace MedX.Service.DTOs.MedicalRecords; +namespace MedX.Service.DTOs.MedicalRecords; public class MedicalRecordCreationDto { diff --git a/src/MedX.Service/DTOs/Payments/PaymentResultDto.cs b/src/MedX.Service/DTOs/Payments/PaymentResultDto.cs index a213b58..dfbc123 100644 --- a/src/MedX.Service/DTOs/Payments/PaymentResultDto.cs +++ b/src/MedX.Service/DTOs/Payments/PaymentResultDto.cs @@ -1,5 +1,4 @@ using MedX.Domain.Enums; -using MedX.Service.DTOs.Appointments; using MedX.Service.DTOs.Patients; namespace MedX.Service.DTOs.Payments; diff --git a/src/MedX.Service/DTOs/Treatments/TreatmentCreationDto.cs b/src/MedX.Service/DTOs/Treatments/TreatmentCreationDto.cs index e1ed832..4fb695a 100644 --- a/src/MedX.Service/DTOs/Treatments/TreatmentCreationDto.cs +++ b/src/MedX.Service/DTOs/Treatments/TreatmentCreationDto.cs @@ -1,6 +1,4 @@ -using MedX.Domain.Entities; - -namespace MedX.Service.DTOs.Treatments; +namespace MedX.Service.DTOs.Treatments; public class TreatmentCreationDto { diff --git a/src/MedX.Service/Exceptions/CustomException.cs b/src/MedX.Service/Exceptions/CustomException.cs index eac2dda..d25cd4c 100644 --- a/src/MedX.Service/Exceptions/CustomException.cs +++ b/src/MedX.Service/Exceptions/CustomException.cs @@ -3,8 +3,8 @@ public class CustomException : Exception { public int StatusCode { get; set; } = 404; - public CustomException(int statusCode,string message) : base(message) - { + public CustomException(int statusCode, string message) : base(message) + { this.StatusCode = statusCode; } } diff --git a/src/MedX.Service/Helpers/CheckPhoneAttribute.cs b/src/MedX.Service/Helpers/CheckPhoneAttribute.cs index ceb0e3b..ad8b2f1 100644 --- a/src/MedX.Service/Helpers/CheckPhoneAttribute.cs +++ b/src/MedX.Service/Helpers/CheckPhoneAttribute.cs @@ -1,12 +1,12 @@ using MedX.Service.Exceptions; -using System.Text.RegularExpressions; using System.ComponentModel.DataAnnotations; +using System.Text.RegularExpressions; public class CheckPhoneAttribute : ValidationAttribute { public override bool IsValid(object value) { - string phoneNumber = value.ToString() + string phoneNumber = value.ToString() ?? throw new CustomException(403, "Invalid phone number"); string pattern = @"^\+998[0-9]{9}$"; diff --git a/src/MedX.Service/Interfaces/IAffairService.cs b/src/MedX.Service/Interfaces/IAffairService.cs index c7aaf18..c333c9f 100644 --- a/src/MedX.Service/Interfaces/IAffairService.cs +++ b/src/MedX.Service/Interfaces/IAffairService.cs @@ -1,5 +1,4 @@ using MedX.Domain.Configurations; -using MedX.Service.DTOs.Administrators; using MedX.Service.DTOs.Services; namespace MedX.Service.Interfaces; diff --git a/src/MedX.Service/Interfaces/IMedicalRecordService.cs b/src/MedX.Service/Interfaces/IMedicalRecordService.cs index d35aa1f..de5307a 100644 --- a/src/MedX.Service/Interfaces/IMedicalRecordService.cs +++ b/src/MedX.Service/Interfaces/IMedicalRecordService.cs @@ -1,5 +1,4 @@ using MedX.Domain.Configurations; -using MedX.Service.DTOs.Appointments; using MedX.Service.DTOs.MedicalRecords; namespace MedX.Service.Interfaces; diff --git a/src/MedX.Service/Interfaces/IPaymentService.cs b/src/MedX.Service/Interfaces/IPaymentService.cs index 9e35d0e..dfceef8 100644 --- a/src/MedX.Service/Interfaces/IPaymentService.cs +++ b/src/MedX.Service/Interfaces/IPaymentService.cs @@ -1,5 +1,4 @@ using MedX.Domain.Configurations; -using MedX.Service.DTOs.Patients; using MedX.Service.DTOs.Payments; namespace MedX.Service.Interfaces; diff --git a/src/MedX.Service/Mappers/MappingProfile.cs b/src/MedX.Service/Mappers/MappingProfile.cs index 9079a5c..001777d 100644 --- a/src/MedX.Service/Mappers/MappingProfile.cs +++ b/src/MedX.Service/Mappers/MappingProfile.cs @@ -1,22 +1,22 @@ using AutoMapper; using MedX.Domain.Entities; -using MedX.Service.DTOs.Rooms; +using MedX.Domain.Entities.Administrators; +using MedX.Domain.Entities.Appointments; +using MedX.Domain.Entities.Assets; +using MedX.Domain.Entities.MedicalRecords; +using MedX.Domain.Entities.Services; +using MedX.Service.DTOs.Administrators; +using MedX.Service.DTOs.Appointments; using MedX.Service.DTOs.Assets; +using MedX.Service.DTOs.CashDesks; using MedX.Service.DTOs.Doctors; -using MedX.Service.DTOs.Services; +using MedX.Service.DTOs.MedicalRecords; using MedX.Service.DTOs.Patients; using MedX.Service.DTOs.Payments; -using MedX.Domain.Entities.Assets; -using MedX.Service.DTOs.CashDesks; -using MedX.Service.DTOs.Treatments; -using MedX.Domain.Entities.Services; -using MedX.Service.DTOs.Appointments; +using MedX.Service.DTOs.Rooms; using MedX.Service.DTOs.ServiceItems; -using MedX.Service.DTOs.Administrators; -using MedX.Service.DTOs.MedicalRecords; -using MedX.Domain.Entities.Appointments; -using MedX.Domain.Entities.MedicalRecords; -using MedX.Domain.Entities.Administrators; +using MedX.Service.DTOs.Services; +using MedX.Service.DTOs.Treatments; namespace MedX.Service.Mappers; diff --git a/src/MedX.Service/Services/AdminService.cs b/src/MedX.Service/Services/AdminService.cs index 8347310..38bdb35 100644 --- a/src/MedX.Service/Services/AdminService.cs +++ b/src/MedX.Service/Services/AdminService.cs @@ -1,16 +1,16 @@ using AutoMapper; -using System.Data; -using MedX.Service.Helpers; using MedX.Data.IRepositories; -using MedX.Service.Interfaces; -using MedX.Service.Exceptions; -using MedX.Service.Extensions; -using MedX.Service.DTOs.Assets; using MedX.Domain.Configurations; +using MedX.Domain.Entities.Administrators; using MedX.Domain.Entities.Assets; -using Microsoft.EntityFrameworkCore; using MedX.Service.DTOs.Administrators; -using MedX.Domain.Entities.Administrators; +using MedX.Service.DTOs.Assets; +using MedX.Service.Exceptions; +using MedX.Service.Extensions; +using MedX.Service.Helpers; +using MedX.Service.Interfaces; +using Microsoft.EntityFrameworkCore; +using System.Data; namespace MedX.Service.Services; @@ -110,7 +110,7 @@ public async Task UpdateAsync(AdminUpdateDto dto) public async Task GetAsync(long id) { - var existAdmin = await this.repository.GetAsync(r => r.Id == id, includes: new[] {"Image"}) + var existAdmin = await this.repository.GetAsync(r => r.Id == id, includes: new[] { "Image" }) ?? throw new NotFoundException($"This Admin not found with id: {id}"); return this.mapper.Map(existAdmin); diff --git a/src/MedX.Service/Services/AffairItemService.cs b/src/MedX.Service/Services/AffairItemService.cs index 252cacf..40185eb 100644 --- a/src/MedX.Service/Services/AffairItemService.cs +++ b/src/MedX.Service/Services/AffairItemService.cs @@ -1,13 +1,13 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Domain.Entities.Services; +using MedX.Service.DTOs.ServiceItems; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; -using MedX.Domain.Entities.Services; using Microsoft.EntityFrameworkCore; -using MedX.Service.DTOs.ServiceItems; namespace MedX.Service.Services; @@ -17,7 +17,7 @@ public class AffairItemService : IAffairItemService private readonly IRepository affairRepository; private readonly IRepository patientRepository; private readonly IRepository affairItemRepository; - public AffairItemService(IMapper mapper, + public AffairItemService(IMapper mapper, IRepository affairRepository, IRepository patientRepository, IRepository affairItemRepository) @@ -33,7 +33,7 @@ public async Task> AddAsync(AffairItemCreationD var existPatient = await this.patientRepository.GetAsync(d => d.Id.Equals(dto.PatientId)) ?? throw new NotFoundException($"This Patient not found with id: {dto.PatientId}"); - if(dto.AffairItems is null || !dto.AffairItems.Any()) + if (dto.AffairItems is null || !dto.AffairItems.Any()) { throw new NotFoundException("No Affair items provided"); } @@ -104,7 +104,7 @@ public async Task GetAsync(long id) public async Task> GetAllAsync(PaginationParams @params, string search = null) { - var allAffairItems = await this.affairItemRepository.GetAll(includes: new[] {"Patient","Affair"}) + var allAffairItems = await this.affairItemRepository.GetAll(includes: new[] { "Patient", "Affair" }) .ToPaginate(@params) .ToListAsync(); diff --git a/src/MedX.Service/Services/AffairService.cs b/src/MedX.Service/Services/AffairService.cs index df5f4e3..8249ed9 100644 --- a/src/MedX.Service/Services/AffairService.cs +++ b/src/MedX.Service/Services/AffairService.cs @@ -1,11 +1,11 @@ using AutoMapper; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities.Services; +using MedX.Service.DTOs.Services; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Service.DTOs.Services; -using MedX.Domain.Configurations; -using MedX.Domain.Entities.Services; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/AppointmentService.cs b/src/MedX.Service/Services/AppointmentService.cs index 5f8a50b..4a77ba4 100644 --- a/src/MedX.Service/Services/AppointmentService.cs +++ b/src/MedX.Service/Services/AppointmentService.cs @@ -1,13 +1,13 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Domain.Entities.Appointments; +using MedX.Service.DTOs.Appointments; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; using Microsoft.EntityFrameworkCore; -using MedX.Service.DTOs.Appointments; -using MedX.Domain.Entities.Appointments; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/AssetService.cs b/src/MedX.Service/Services/AssetService.cs index 3c10e25..2982a91 100644 --- a/src/MedX.Service/Services/AssetService.cs +++ b/src/MedX.Service/Services/AssetService.cs @@ -1,9 +1,9 @@ -using MedX.Service.Helpers; -using MedX.Data.IRepositories; +using MedX.Data.IRepositories; +using MedX.Domain.Entities.Assets; +using MedX.Service.DTOs.Assets; using MedX.Service.Extensions; +using MedX.Service.Helpers; using MedX.Service.Interfaces; -using MedX.Service.DTOs.Assets; -using MedX.Domain.Entities.Assets; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/AuthService.cs b/src/MedX.Service/Services/AuthService.cs index f387df4..43e1506 100644 --- a/src/MedX.Service/Services/AuthService.cs +++ b/src/MedX.Service/Services/AuthService.cs @@ -1,13 +1,13 @@ -using System.Text; -using MedX.Service.Helpers; -using System.Security.Claims; +using MedX.Data.IRepositories; +using MedX.Domain.Entities.Administrators; using MedX.Service.Exceptions; -using MedX.Data.IRepositories; +using MedX.Service.Helpers; using MedX.Service.Interfaces; +using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; -using Microsoft.Extensions.Configuration; -using MedX.Domain.Entities.Administrators; +using System.Security.Claims; +using System.Text; namespace MedX.Service.Services; @@ -23,7 +23,7 @@ public AuthService(IConfiguration configuration, IRepository repo } public async Task GenerateTokenAsync(string phone, string password) { - Administrator administrator =await this.repository.GetAsync(a => a.Phone.Equals(phone)); + Administrator administrator = await this.repository.GetAsync(a => a.Phone.Equals(phone)); if (administrator is null) throw new NotFoundException($"This phone is not found {phone}"); diff --git a/src/MedX.Service/Services/CashDeskService.cs b/src/MedX.Service/Services/CashDeskService.cs index 9271215..4b026fc 100644 --- a/src/MedX.Service/Services/CashDeskService.cs +++ b/src/MedX.Service/Services/CashDeskService.cs @@ -2,9 +2,7 @@ using MedX.Data.IRepositories; using MedX.Domain.Configurations; using MedX.Domain.Entities; -using MedX.Domain.Entities.Services; using MedX.Service.DTOs.CashDesks; -using MedX.Service.DTOs.Services; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; diff --git a/src/MedX.Service/Services/DoctorService.cs b/src/MedX.Service/Services/DoctorService.cs index 88369d8..ad55b58 100644 --- a/src/MedX.Service/Services/DoctorService.cs +++ b/src/MedX.Service/Services/DoctorService.cs @@ -1,13 +1,13 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Domain.Entities.Assets; +using MedX.Service.DTOs.Assets; +using MedX.Service.DTOs.Doctors; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Service.DTOs.Assets; -using MedX.Service.DTOs.Doctors; -using MedX.Domain.Configurations; -using MedX.Domain.Entities.Assets; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; @@ -43,7 +43,7 @@ public async Task AddAsync(DoctorCreationDto dto) AccountNumber = accountNumber, }; - if(dto.Image is not null ) + if (dto.Image is not null) { var uploadedImage = await this.assetService.UploadAsync(new AssetCreationDto { FormFile = dto.Image }); var createdImage = new Asset diff --git a/src/MedX.Service/Services/MedicalRecordService.cs b/src/MedX.Service/Services/MedicalRecordService.cs index 1242a54..60a1b94 100644 --- a/src/MedX.Service/Services/MedicalRecordService.cs +++ b/src/MedX.Service/Services/MedicalRecordService.cs @@ -1,14 +1,13 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Domain.Entities.MedicalRecords; +using MedX.Service.DTOs.MedicalRecords; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; using Microsoft.EntityFrameworkCore; -using MedX.Service.DTOs.Appointments; -using MedX.Service.DTOs.MedicalRecords; -using MedX.Domain.Entities.MedicalRecords; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/PatientService.cs b/src/MedX.Service/Services/PatientService.cs index 9280a4b..fffb214 100644 --- a/src/MedX.Service/Services/PatientService.cs +++ b/src/MedX.Service/Services/PatientService.cs @@ -1,11 +1,11 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Service.DTOs.Patients; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; -using MedX.Service.DTOs.Patients; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; @@ -28,7 +28,7 @@ public async Task AddAsync(PatientCreationDto dto) patient = await this.repository.GetAsync(u => u.Pinfl.Equals(dto.Pinfl)); if (patient is not null) throw new AlreadyExistException($"This patient is already exist with Pinfl {dto.Pinfl}"); - + Patient mappedPatient = mapper.Map(dto); mappedPatient.AccountNumber = GenerateAccountNumber(); diff --git a/src/MedX.Service/Services/PaymentService.cs b/src/MedX.Service/Services/PaymentService.cs index 0847f03..cd63fce 100644 --- a/src/MedX.Service/Services/PaymentService.cs +++ b/src/MedX.Service/Services/PaymentService.cs @@ -1,11 +1,11 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Service.DTOs.Payments; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; -using MedX.Service.DTOs.Payments; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/RoomService.cs b/src/MedX.Service/Services/RoomService.cs index da56d77..ab27fe2 100644 --- a/src/MedX.Service/Services/RoomService.cs +++ b/src/MedX.Service/Services/RoomService.cs @@ -1,13 +1,13 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Domain.Entities.Assets; +using MedX.Service.DTOs.Assets; using MedX.Service.DTOs.Rooms; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Service.DTOs.Assets; -using MedX.Domain.Configurations; -using MedX.Domain.Entities.Assets; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; diff --git a/src/MedX.Service/Services/TreatmentService.cs b/src/MedX.Service/Services/TreatmentService.cs index 5d521f4..fd3abde 100644 --- a/src/MedX.Service/Services/TreatmentService.cs +++ b/src/MedX.Service/Services/TreatmentService.cs @@ -1,11 +1,11 @@ using AutoMapper; -using MedX.Domain.Entities; using MedX.Data.IRepositories; +using MedX.Domain.Configurations; +using MedX.Domain.Entities; +using MedX.Service.DTOs.Treatments; using MedX.Service.Exceptions; using MedX.Service.Extensions; using MedX.Service.Interfaces; -using MedX.Domain.Configurations; -using MedX.Service.DTOs.Treatments; using Microsoft.EntityFrameworkCore; namespace MedX.Service.Services; @@ -44,11 +44,11 @@ public async Task AddAsync(TreatmentCreationDto dto) var mappedTreatment = this.mapper.Map(dto); if (existRoom.Busy + 1 <= existRoom.Quantity) { - if(existRoom.Gender != existPatient.Gender && existRoom.Busy != 0) + if (existRoom.Gender != existPatient.Gender && existRoom.Busy != 0) { throw new CustomException(400, "The gender don't match in this room"); } - if(existRoom.Busy == 0) + if (existRoom.Busy == 0) { existRoom.Gender = existPatient.Gender; } @@ -71,7 +71,7 @@ public async Task AddAsync(TreatmentCreationDto dto) public async Task DeleteAsync(long id) { - var existTreatment = await this.treatmentRepository.GetAsync(r => r.Id == id, includes: new[] {"Patient", "Room"}) + var existTreatment = await this.treatmentRepository.GetAsync(r => r.Id == id, includes: new[] { "Patient", "Room" }) ?? throw new NotFoundException($"This Treatment not found with id: {id}"); existTreatment.Room.Busy -= 1; @@ -174,7 +174,7 @@ public async Task> GetAllByRoomIdAsync(long room var existRoom = await this.roomRepository.GetAsync(r => r.Id == roomId) ?? throw new NotFoundException($"This room is not found with id = {roomId}"); - var rooms = await this.treatmentRepository.GetAll(r => r.RoomId == roomId) .ToListAsync(); + var rooms = await this.treatmentRepository.GetAll(r => r.RoomId == roomId).ToListAsync(); return this.mapper.Map>(rooms); } diff --git a/src/MedX.Service/Validators/PhoneNumberValidator.cs b/src/MedX.Service/Validators/PhoneNumberValidator.cs new file mode 100644 index 0000000..4841250 --- /dev/null +++ b/src/MedX.Service/Validators/PhoneNumberValidator.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.RegularExpressions; + +namespace MedX.Service.Validators; + +public class PhoneNumberValidator : ValidationAttribute +{ + public override bool IsValid(object value) + { + string phoneNumber = value.ToString() ?? ""; + string pattern = @"^\+998(90|91|93|94|97|50|88|20|33|70|99)[0-9]{7}$"; + return Regex.IsMatch(phoneNumber, pattern); + } +} \ No newline at end of file diff --git a/src/MedX.WebApi/.config/dotnet-tools.json b/src/MedX.WebApi/.config/dotnet-tools.json new file mode 100644 index 0000000..96be437 --- /dev/null +++ b/src/MedX.WebApi/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "7.0.11", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/src/MedX.WebApi/Controllers/AdminsController.cs b/src/MedX.WebApi/Controllers/AdminsController.cs index a822f1b..825f9f5 100644 --- a/src/MedX.WebApi/Controllers/AdminsController.cs +++ b/src/MedX.WebApi/Controllers/AdminsController.cs @@ -1,8 +1,8 @@ -using MedX.WebApi.Models; +using MedX.Domain.Configurations; +using MedX.Service.DTOs.Administrators; using MedX.Service.Interfaces; +using MedX.WebApi.Models; using Microsoft.AspNetCore.Mvc; -using MedX.Domain.Configurations; -using MedX.Service.DTOs.Administrators; namespace MedX.WebApi.Controllers; diff --git a/src/MedX.WebApi/Controllers/AffairItemsController.cs b/src/MedX.WebApi/Controllers/AffairItemsController.cs index 8f80101..8777ed2 100644 --- a/src/MedX.WebApi/Controllers/AffairItemsController.cs +++ b/src/MedX.WebApi/Controllers/AffairItemsController.cs @@ -1,8 +1,8 @@ -using MedX.WebApi.Models; +using MedX.Domain.Configurations; +using MedX.Service.DTOs.ServiceItems; using MedX.Service.Interfaces; +using MedX.WebApi.Models; using Microsoft.AspNetCore.Mvc; -using MedX.Domain.Configurations; -using MedX.Service.DTOs.ServiceItems; namespace MedX.WebApi.Controllers; @@ -47,7 +47,7 @@ public async Task UpdateAsync(AffairItemUpdateDto dto) }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, [FromQuery] string search = null) { return Ok(new Response @@ -69,7 +69,7 @@ public async Task GetAllAsync([FromQuery] PaginationParams @param }); } - [HttpPut("get-all-by-service/{serviceId:long}")] + [HttpGet("get-all-by-service/{serviceId:long}")] public async Task GetAllByAffairIdAsync([FromQuery] long affairId, PaginationParams @params, [FromQuery] string search = null) { return Ok(new Response @@ -80,7 +80,7 @@ public async Task GetAllByAffairIdAsync([FromQuery] long affairId }); } - [HttpPut("get-all-by-patient/{patientId:long}")] + [HttpGet("get-all-by-patient/{patientId:long}")] public async Task GetAllByPatientIdAsync([FromQuery] long patientId, PaginationParams @params, [FromQuery] string search = null) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/AffairsController.cs b/src/MedX.WebApi/Controllers/AffairsController.cs index c951ca4..d7c09e9 100644 --- a/src/MedX.WebApi/Controllers/AffairsController.cs +++ b/src/MedX.WebApi/Controllers/AffairsController.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync(AffairUpdateDto dto) }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, [FromQuery] string search = null) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/AppointmentsController.cs b/src/MedX.WebApi/Controllers/AppointmentsController.cs index b437ac0..195762e 100644 --- a/src/MedX.WebApi/Controllers/AppointmentsController.cs +++ b/src/MedX.WebApi/Controllers/AppointmentsController.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync([FromForm] AppointmentUpdateDto dto }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, string search) { return Ok(new Response @@ -69,7 +69,7 @@ public async Task GetAllAsync([FromQuery] PaginationParams @param }); } - [HttpPut("get-all-by-patient/{patientId:long}")] + [HttpGet("get-all-by-patient/{patientId:long}")] public async Task GetAllByPatientIdAsync(long patientId) { return Ok(new Response @@ -80,7 +80,7 @@ public async Task GetAllByPatientIdAsync(long patientId) }); } - [HttpPut("get-all-by-doctor/{doctorId:long}")] + [HttpGet("get-all-by-doctor/{doctorId:long}")] public async Task GetAllByDoctorIdAsync(long doctorId, PaginationParams @params, string search = null) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/BaseController.cs b/src/MedX.WebApi/Controllers/BaseController.cs index d63dc34..3807856 100644 --- a/src/MedX.WebApi/Controllers/BaseController.cs +++ b/src/MedX.WebApi/Controllers/BaseController.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace MedX.WebApi.Controllers; diff --git a/src/MedX.WebApi/Controllers/DoctorsController.cs b/src/MedX.WebApi/Controllers/DoctorsController.cs index a7af77e..10d4d3d 100644 --- a/src/MedX.WebApi/Controllers/DoctorsController.cs +++ b/src/MedX.WebApi/Controllers/DoctorsController.cs @@ -26,11 +26,11 @@ public async Task DeleteAsync(long id) public async Task UpdateAsync([FromForm] DoctorUpdateDto dto) => Ok(new Response { Data = await doctorService.UpdateAsync(dto) }); - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) => Ok(new Response { Data = await doctorService.GetAsync(id) }); - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, string search) => Ok(new Response { Data = await doctorService.GetAllAsync(@params, search) }); } diff --git a/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs b/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs index cf927e9..cabe911 100644 --- a/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs +++ b/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs @@ -1,5 +1,4 @@ using MedX.Domain.Configurations; -using MedX.Service.DTOs.Appointments; using MedX.Service.DTOs.MedicalRecords; using MedX.Service.Interfaces; using MedX.WebApi.Models; diff --git a/src/MedX.WebApi/Extensions/ServiceCollection.cs b/src/MedX.WebApi/Extensions/ServiceCollection.cs index 73c893b..a0b57de 100644 --- a/src/MedX.WebApi/Extensions/ServiceCollection.cs +++ b/src/MedX.WebApi/Extensions/ServiceCollection.cs @@ -1,8 +1,8 @@ -using MedX.Service.Mappers; -using MedX.Service.Services; +using MedX.Data.IRepositories; using MedX.Data.Repositories; -using MedX.Data.IRepositories; using MedX.Service.Interfaces; +using MedX.Service.Mappers; +using MedX.Service.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; diff --git a/src/MedX.WebApi/Program.cs b/src/MedX.WebApi/Program.cs index 2fbeb79..3a7e9db 100644 --- a/src/MedX.WebApi/Program.cs +++ b/src/MedX.WebApi/Program.cs @@ -40,7 +40,7 @@ var app = builder.Build(); // Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) +if (app.Environment.IsDevelopment() || app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(); diff --git a/test/MedX.Tests/GlobalUsings.cs b/test/MedX.Tests/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/test/MedX.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/test/MedX.Tests/MedX.Tests.csproj b/test/MedX.Tests/MedX.Tests.csproj new file mode 100644 index 0000000..0204de9 --- /dev/null +++ b/test/MedX.Tests/MedX.Tests.csproj @@ -0,0 +1,25 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs new file mode 100644 index 0000000..b83cd99 --- /dev/null +++ b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs @@ -0,0 +1,11 @@ +namespace MedX.Tests.ValidatorTests; + +public class PhoneNumberValidatorTest +{ + [Theory] + [InlineData(null)] + public void valid(string phoneNumber) + { + + } +} \ No newline at end of file From b2d8490e17230c204ee70ab015f6bef38248623a Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Sat, 28 Oct 2023 23:06:44 +0500 Subject: [PATCH 02/10] Fixed type methods --- src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs | 8 ++++---- src/MedX.WebApi/Controllers/PaymentsController.cs | 6 +++--- src/MedX.WebApi/Controllers/RoomsController.cs | 4 ++-- src/MedX.WebApi/Controllers/TreatmentsController.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs b/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs index cabe911..7c98bd4 100644 --- a/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs +++ b/src/MedX.WebApi/Controllers/MedicalRecordsControllers.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync([FromForm] MedicalRecordUpdateDto d }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, string search) { return Ok(new Response @@ -69,7 +69,7 @@ public async Task GetAllAsync([FromQuery] PaginationParams @param }); } - [HttpPut("get-all-by-patient/{patientId:long}")] + [HttpGet("get-all-by-patient/{patientId:long}")] public async Task GetAllByPatientIdAsync(long patientId) { return Ok(new Response @@ -80,7 +80,7 @@ public async Task GetAllByPatientIdAsync(long patientId) }); } - [HttpPut("get-all-by-doctor/{doctorId:long}")] + [HttpGet("get-all-by-doctor/{doctorId:long}")] public async Task GetAllByDoctorIdAsync(long doctorId, PaginationParams @params, string search = null) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/PaymentsController.cs b/src/MedX.WebApi/Controllers/PaymentsController.cs index 9296c53..b1f9e9b 100644 --- a/src/MedX.WebApi/Controllers/PaymentsController.cs +++ b/src/MedX.WebApi/Controllers/PaymentsController.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync([FromForm] PaymentUpdateDto dto) }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, string search) { return Ok(new Response @@ -69,7 +69,7 @@ public async Task GetAllAsync([FromQuery] PaginationParams @param }); } - [HttpPut("get-all-by-patient/{patientId:long}")] + [HttpGet("get-all-by-patient/{patientId:long}")] public async Task GetAllByPatientIdAsync(long patientId) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/RoomsController.cs b/src/MedX.WebApi/Controllers/RoomsController.cs index 1c66156..1a317f9 100644 --- a/src/MedX.WebApi/Controllers/RoomsController.cs +++ b/src/MedX.WebApi/Controllers/RoomsController.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync(RoomUpdateDto dto) }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, [FromQuery] int? search) { return Ok(new Response diff --git a/src/MedX.WebApi/Controllers/TreatmentsController.cs b/src/MedX.WebApi/Controllers/TreatmentsController.cs index 13c04d6..0bc2b95 100644 --- a/src/MedX.WebApi/Controllers/TreatmentsController.cs +++ b/src/MedX.WebApi/Controllers/TreatmentsController.cs @@ -47,7 +47,7 @@ public async Task UpdateAsync(TreatmentUpdateDto dto) }); } - [HttpPut("get/{id:long}")] + [HttpGet("get/{id:long}")] public async Task GetAsync(long id) { return Ok(new Response @@ -58,7 +58,7 @@ public async Task GetAsync(long id) }); } - [HttpPut("get-all")] + [HttpGet("get-all")] public async Task GetAllAsync([FromQuery] PaginationParams @params, string search) { return Ok(new Response From 8bb9eb994e43ce12aa906de7b1b8e53522785e09 Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Sun, 29 Oct 2023 17:59:12 +0500 Subject: [PATCH 03/10] FIlled to examples PhoneValidationTest --- test/MedX.Tests/MedX.Tests.csproj | 6 +++++- .../ValidatorTests/PhoneNumberValidatorTest.cs | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test/MedX.Tests/MedX.Tests.csproj b/test/MedX.Tests/MedX.Tests.csproj index 0204de9..86bbfbc 100644 --- a/test/MedX.Tests/MedX.Tests.csproj +++ b/test/MedX.Tests/MedX.Tests.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -22,4 +22,8 @@ + + + + diff --git a/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs index b83cd99..ca28b6a 100644 --- a/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs +++ b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs @@ -1,11 +1,19 @@ -namespace MedX.Tests.ValidatorTests; +using MedX.Service.Validators; + +namespace MedX.Tests.ValidatorTests; public class PhoneNumberValidatorTest { [Theory] [InlineData(null)] - public void valid(string phoneNumber) + [InlineData("+99937349808")] + [InlineData("+9989373498O8")] + [InlineData("+998927349808")] + [InlineData("998937349808")] + public void ShoulReturnFalse(string phoneNumber) { - + var validator = new PhoneNumberValidator(); + var result = validator.IsValid(phoneNumber); + Assert.False(result); } } \ No newline at end of file From 724ca46a479a5a0a4be89afb5a2e4c165bf35e6e Mon Sep 17 00:00:00 2001 From: Muqimjon Mamadaliyev <58146206+muqimjon@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:42:20 +0500 Subject: [PATCH 04/10] Create workflow.yml --- .github/workflows/med-x.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/med-x.yml diff --git a/.github/workflows/med-x.yml b/.github/workflows/med-x.yml new file mode 100644 index 0000000..232903d --- /dev/null +++ b/.github/workflows/med-x.yml @@ -0,0 +1,27 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "unidevs" ] + pull_request: + branches: [ "unidevs" ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Setup .NET 7 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore From f8cb6053159b9c05e00bb05567a643cf31802467 Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Tue, 31 Oct 2023 21:36:10 +0500 Subject: [PATCH 05/10] added phone valid correct test --- src/MedX.Service/Validators/PhoneNumberValidator.cs | 2 +- .../ValidatorTests/PhoneNumberValidatorTest.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/MedX.Service/Validators/PhoneNumberValidator.cs b/src/MedX.Service/Validators/PhoneNumberValidator.cs index 4841250..5d0ec75 100644 --- a/src/MedX.Service/Validators/PhoneNumberValidator.cs +++ b/src/MedX.Service/Validators/PhoneNumberValidator.cs @@ -7,7 +7,7 @@ public class PhoneNumberValidator : ValidationAttribute { public override bool IsValid(object value) { - string phoneNumber = value.ToString() ?? ""; + string phoneNumber = (string)value ?? ""; string pattern = @"^\+998(90|91|93|94|97|50|88|20|33|70|99)[0-9]{7}$"; return Regex.IsMatch(phoneNumber, pattern); } diff --git a/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs index ca28b6a..ef9f643 100644 --- a/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs +++ b/test/MedX.Tests/ValidatorTests/PhoneNumberValidatorTest.cs @@ -5,7 +5,6 @@ namespace MedX.Tests.ValidatorTests; public class PhoneNumberValidatorTest { [Theory] - [InlineData(null)] [InlineData("+99937349808")] [InlineData("+9989373498O8")] [InlineData("+998927349808")] @@ -16,4 +15,14 @@ public void ShoulReturnFalse(string phoneNumber) var result = validator.IsValid(phoneNumber); Assert.False(result); } + + + [Theory] + [InlineData("+998937349808")] + public void ShoulReturnTrue(string phoneNumber) + { + var validator = new PhoneNumberValidator(); + var result = validator.IsValid(phoneNumber); + Assert.True(result); + } } \ No newline at end of file From b31d293744629326652f6b7511e2707ef6a0e769 Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Wed, 1 Nov 2023 14:18:33 +0500 Subject: [PATCH 06/10] Test job added --- .github/workflows/med-x.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/med-x.yml b/.github/workflows/med-x.yml index 232903d..9172195 100644 --- a/.github/workflows/med-x.yml +++ b/.github/workflows/med-x.yml @@ -1,6 +1,3 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net - name: .NET on: @@ -25,3 +22,20 @@ jobs: run: dotnet restore - name: Build run: dotnet build --no-restore + + test: + name: Test + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Setup .NET 7 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore + - name: Testing + run: dotnet test --no-restore \ No newline at end of file From 75eb749b2532e855d36538a55cf4bae61b810215 Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Thu, 2 Nov 2023 23:07:44 +0500 Subject: [PATCH 07/10] Deleted default test class --- MedX.test/UnitTest1.cs | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 MedX.test/UnitTest1.cs diff --git a/MedX.test/UnitTest1.cs b/MedX.test/UnitTest1.cs deleted file mode 100644 index e533713..0000000 --- a/MedX.test/UnitTest1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MedX.test; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - - } -} \ No newline at end of file From 4a7f03c74b2633e58884d4c5399cbdea277ecea2 Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Thu, 2 Nov 2023 23:08:33 +0500 Subject: [PATCH 08/10] Deleted test folders --- MedX.Tests/MedX.Tests.csproj | 25 ------------------------- MedX.Tests/UnitTest1.cs | 10 ---------- MedX.Tests/Usings.cs | 1 - MedX.test/MedX.test.csproj | 25 ------------------------- MedX.test/Usings.cs | 1 - 5 files changed, 62 deletions(-) delete mode 100644 MedX.Tests/MedX.Tests.csproj delete mode 100644 MedX.Tests/UnitTest1.cs delete mode 100644 MedX.Tests/Usings.cs delete mode 100644 MedX.test/MedX.test.csproj delete mode 100644 MedX.test/Usings.cs diff --git a/MedX.Tests/MedX.Tests.csproj b/MedX.Tests/MedX.Tests.csproj deleted file mode 100644 index 5e9fe29..0000000 --- a/MedX.Tests/MedX.Tests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net7.0 - enable - enable - - false - true - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/MedX.Tests/UnitTest1.cs b/MedX.Tests/UnitTest1.cs deleted file mode 100644 index a3d8d67..0000000 --- a/MedX.Tests/UnitTest1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MedX.Tests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - - } -} \ No newline at end of file diff --git a/MedX.Tests/Usings.cs b/MedX.Tests/Usings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/MedX.Tests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file diff --git a/MedX.test/MedX.test.csproj b/MedX.test/MedX.test.csproj deleted file mode 100644 index 5e9fe29..0000000 --- a/MedX.test/MedX.test.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net7.0 - enable - enable - - false - true - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/MedX.test/Usings.cs b/MedX.test/Usings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/MedX.test/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file From 3d99a0281e1f89b8dbd449ea29769ff54aa92b5b Mon Sep 17 00:00:00 2001 From: Muqimjon Date: Fri, 3 Nov 2023 18:54:55 +0500 Subject: [PATCH 09/10] Same changes added --- src/MedX.Domain/Entities/CashDesk.cs | 1 + src/MedX.Domain/Entities/Rooms/Room.cs | 10 +--------- .../DTOs/CashDesks/CashDescBalanceResultDto.cs | 6 ++++++ src/MedX.Service/DTOs/CashDesks/CashDeskResultDto.cs | 2 +- src/MedX.Service/Interfaces/IAdminService.cs | 10 ++++++++++ src/MedX.Service/Services/AdminService.cs | 6 ++++++ 6 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 src/MedX.Service/DTOs/CashDesks/CashDescBalanceResultDto.cs diff --git a/src/MedX.Domain/Entities/CashDesk.cs b/src/MedX.Domain/Entities/CashDesk.cs index 5325dfb..4847453 100644 --- a/src/MedX.Domain/Entities/CashDesk.cs +++ b/src/MedX.Domain/Entities/CashDesk.cs @@ -6,6 +6,7 @@ public class CashDesk : Auditable { public string Description { get; set; } public decimal Balance { get; set; } + public decimal Amount { get; set; } public string AccountNumber { get; set; } public bool IsIncome { get; set; } } \ No newline at end of file diff --git a/src/MedX.Domain/Entities/Rooms/Room.cs b/src/MedX.Domain/Entities/Rooms/Room.cs index 7d5b2b9..4c4aa86 100644 --- a/src/MedX.Domain/Entities/Rooms/Room.cs +++ b/src/MedX.Domain/Entities/Rooms/Room.cs @@ -6,17 +6,9 @@ namespace MedX.Domain.Entities; public class Room : Auditable { - private int busy; public int Number { get; set; } public int Quantity { get; set; } - public int Busy - { - get => busy; - set - { - busy += busy + value > Quantity ? 0 : value; - } - } + public int Busy { get; set; } public Gender Gender { get; set; } public TypeOfRoom Type { get; set; } public long? ImageId { get; set; } diff --git a/src/MedX.Service/DTOs/CashDesks/CashDescBalanceResultDto.cs b/src/MedX.Service/DTOs/CashDesks/CashDescBalanceResultDto.cs new file mode 100644 index 0000000..5533814 --- /dev/null +++ b/src/MedX.Service/DTOs/CashDesks/CashDescBalanceResultDto.cs @@ -0,0 +1,6 @@ +namespace MedX.Service.DTOs.CashDesks; + +public class CashDescBalanceResultDto +{ + public decimal Balance { get; set; } +} \ No newline at end of file diff --git a/src/MedX.Service/DTOs/CashDesks/CashDeskResultDto.cs b/src/MedX.Service/DTOs/CashDesks/CashDeskResultDto.cs index 13bbf8f..669c7f2 100644 --- a/src/MedX.Service/DTOs/CashDesks/CashDeskResultDto.cs +++ b/src/MedX.Service/DTOs/CashDesks/CashDeskResultDto.cs @@ -4,7 +4,7 @@ public class CashDeskResultDto { public long Id { get; set; } public string Description { get; set; } - public decimal Balance { get; set; } + public decimal Amount { get; set; } public string AccountNumber { get; set; } public bool IsIncome { get; set; } } diff --git a/src/MedX.Service/Interfaces/IAdminService.cs b/src/MedX.Service/Interfaces/IAdminService.cs index c52e5af..488df56 100644 --- a/src/MedX.Service/Interfaces/IAdminService.cs +++ b/src/MedX.Service/Interfaces/IAdminService.cs @@ -7,7 +7,17 @@ public interface IAdminService { Task AddAsync(AdminCreationDto dto); Task UpdateAsync(AdminUpdateDto dto); + /// + /// kzsidgfuiyasbdccjzbcdiluasbcviuds + /// + /// + /// uhhzsdhbsDbhsdjhbsdfjhbds Task DeleteAsync(long id); + /// + /// dsfjhbvbddsdbcbusubdcv + /// + /// + /// Task GetAsync(long id); Task> GetAllAsync(PaginationParams @params, string search = null); } \ No newline at end of file diff --git a/src/MedX.Service/Services/AdminService.cs b/src/MedX.Service/Services/AdminService.cs index 38bdb35..acbd175 100644 --- a/src/MedX.Service/Services/AdminService.cs +++ b/src/MedX.Service/Services/AdminService.cs @@ -62,6 +62,12 @@ public async Task AddAsync(AdminCreationDto dto) return this.mapper.Map(mappedAdmin); } + /// + /// + /// + /// + /// + /// public async Task DeleteAsync(long id) { var existAdmin = await this.repository.GetAsync(r => r.Id == id) From b0e38bfa44c27f118bb547ffae7d7c57ab2d2df4 Mon Sep 17 00:00:00 2001 From: Muqimjon Mamadaliyev <58146206+muqimjon@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:06:13 +0500 Subject: [PATCH 10/10] Update med-x.yml --- .github/workflows/med-x.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/med-x.yml b/.github/workflows/med-x.yml index 9172195..a3b0cf1 100644 --- a/.github/workflows/med-x.yml +++ b/.github/workflows/med-x.yml @@ -3,8 +3,6 @@ name: .NET on: push: branches: [ "unidevs" ] - pull_request: - branches: [ "unidevs" ] jobs: build: @@ -38,4 +36,4 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Testing - run: dotnet test --no-restore \ No newline at end of file + run: dotnet test --no-restore