Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/workflows/main.yml

This file was deleted.

17 changes: 13 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
<EnablePackageVersionOverride>false</EnablePackageVersionOverride>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Itmo.Dev.Editorconfig" Version="1.0.2" />
<PackageVersion Include="Itmo.Dev.Platform.Logging" Version="1.0.89" />
<PackageVersion Include="Itmo.Dev.Platform.Postgres" Version="1.1.89" />
<PackageVersion Include="DotNet.Testcontainers" Version="1.6.0" />
<PackageVersion Include="EntityFramework" Version="6.4.4" />
<PackageVersion Include="Itmo.Dev.Editorconfig" Version="1.0.1" />
<PackageVersion Include="Itmo.Dev.Platform.Logging" Version="1.0.82" />
<PackageVersion Include="Itmo.Dev.Platform.Postgres" Version="1.1.82" />
<PackageVersion Include="Itmo.Dev.Platform.Common" Version="1.1.82" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.15" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="SourceKit.Generators.Builder" Version="1.1.24" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.435" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Testcontainers" Version="3.7.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="3.7.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\DoctorsHelp.Infrastructure.Persistence\DoctorsHelp.Infrastructure.Persistence.csproj" />
<ProjectReference Include="..\DoctorsHelp.Application.Models\DoctorsHelp.Application.Models.csproj"/>
</ItemGroup>

<ItemGroup>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace DoctorsHelp.Application.Contracts;

public interface IAppointmentService
{
Appointment Create(User patient, Schedule schedule);
Appointment Create(Guid patientId, int scheduleId);

Appointment GetAppointment(int patientId);
Appointment? GetAppointment(int patientId);

Appointment Update(int id, Dictionary<string, string> data);

bool Delete(int id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ namespace DoctorsHelp.Application.Contracts;

public interface IEmployeeService
{
Employee Create(User user, Specialization specialization, string graduate, string experience);
Employee Create(Guid userId, int specializationId, string graduate, string experience);

Employee GetEmployee();

Employee GetById(int id);
Employee? GetEmployee(int employeeId);

Employee Update(int id, Dictionary<string, string> data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace DoctorsHelp.Application.Contracts;

public interface IReviewService
{
Review Create(Appointment appointment, int grade, string comment);
Review Create(int appointmentId, int? grade, string comment);

Review GetReview(int appointmentId);
Review? GetReview(int reviewId);

Review Update(int id, Dictionary<string, string> data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace DoctorsHelp.Application.Contracts;

public interface IScheduleService
{
Review Create(Employee employee, DateTime dateStart, DateTime dateEnd);
Schedule Create(int employeeId, DateTime? dateStart, DateTime? dateEnd);

Review GeSchedule(int employeeId);
Schedule? GetSchedule(int scheduleId);

Review Update(int id, Dictionary<string, string> data);
Schedule Update(int id, Dictionary<string, string> data);

bool Delete(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface ISpecializationService
{
Specialization Create(string name, string description);

Specialization GetSpecialization(int id);
Specialization? GetSpecialization(int id);

Specialization Update(int id, Dictionary<string, string> data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ namespace DoctorsHelp.Application.Contracts;

public interface IUserService
{
User Register(string name, string surname, string phone, string email, string password, DateTime birthdate);
User Register(string name, string surname, string phone, string email, string password, DateOnly? birthdate);

User Login(string phone, string password);
User? GetUser(Guid id);

User GetUser(int id);
User UpdateUser(Guid id, Dictionary<string, string> data);

User Update(int id, Dictionary<string, string> data);

bool Delete(int id);
bool DeleteUser(Guid id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using DoctorsHelp.Application.Models;
using DoctorsHelp.Infrastructure.Persistence.Converters;
using DoctorsHelp.Infrastructure.Persistence.Interfaces;
using DoctorsHelp.Infrastructure.Persistence.Repositories;
using Infrastructure.Persistence.Models;

namespace DoctorsHelp.Application.Contracts.Services;

public class AppointmentService : IAppointmentService
{
private readonly IAppointmentRepository _appointmentRepository;
private readonly IUserRepository _patientRepository;
private readonly IScheduleRepository _scheduleRepository;

public AppointmentService(AppointmentRepository appointmentRepository, UserRepository userRepository, ScheduleRepository scheduleRepository)
{
_appointmentRepository = appointmentRepository;
_patientRepository = userRepository;
_scheduleRepository = scheduleRepository;
}

public Appointment Create(Guid patientId, int scheduleId)
{
User patient = UserConverter.UserModelToUser(_patientRepository.GetUser(patientId));
Schedule schedule = ScheduleConverter.ScheduleModelToSchedule(_scheduleRepository.GetSchedule(scheduleId));

var appointment = new Appointment
{
// Assuming Appointment has a constructor or properties for this
Patient = patient,
Schedule = schedule,
};
_appointmentRepository.Add(appointment);
return appointment;
}

public Appointment? GetAppointment(int patientId)
{
var appointmentModel = _appointmentRepository.GetAppointment(patientId);

return AppointmentConverter.AppointmentModelToAppointment(appointmentModel);
}

public Appointment Update(int id, Dictionary<string, string> data)
{
AppointmentModel appointmentToUpdate = _appointmentRepository.GetAppointment(id);

foreach (var entry in data)
{
switch (entry.Key)
{
case "PatientId":
Guid patientId;
if (Guid.TryParse(entry.Value, out patientId))
appointmentToUpdate.PatientId = patientId;
break;
case "ScheduleId":
int scheduleId;
if (int.TryParse(entry.Value, out scheduleId))
appointmentToUpdate.ScheduleId = scheduleId;
break;
case "Status":
int status;
if (int.TryParse(entry.Value, out status))
appointmentToUpdate.Status = status;
break;
}
}

return AppointmentConverter.AppointmentModelToAppointment(appointmentToUpdate);
}

public bool Delete(int id)
{
return _appointmentRepository.Delete(new Appointment { Id = id, });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using DoctorsHelp.Application.Models;
using DoctorsHelp.Infrastructure.Persistence.Converters;
using DoctorsHelp.Infrastructure.Persistence.Interfaces;
using DoctorsHelp.Infrastructure.Persistence.Repositories;
using Infrastructure.Persistence.Models;

namespace DoctorsHelp.Application.Contracts.Services;

public class EmployeeService : IEmployeeService
{
private readonly IEmployeeRepository _employeeRepository;
private readonly IUserRepository _userRepository;
private readonly ISpecializationRepository _specializationRepository;

public EmployeeService(EmployeeRepository appointmentRepository, UserRepository userRepository, SpecializationRepository specializationRepository)
{
_employeeRepository = appointmentRepository;
_userRepository = userRepository;
_specializationRepository = specializationRepository;
}

public Employee Create(Guid userId, int specializationId, string graduate, string experience)
{
User user = UserConverter.UserModelToUser(_userRepository.GetUser(userId));
Specialization specialization = SpecializationConverter.SpecializationModelToSpecialization(_specializationRepository.GetSpecialization(specializationId));

var employee = new Employee
{
User = user,
Specialization = specialization,
Graduate = graduate,
Experience = experience,
};
_employeeRepository.Add(employee);
return employee;
}

public Employee? GetEmployee(int employeeId)
{
var employeeModel = _employeeRepository.GetEmployee(employeeId);

return EmployeeConverter.EmployeeModelToEmployee(employeeModel);
}

public Employee Update(int id, Dictionary<string, string> data)
{
EmployeeModel employeeToUpdate = _employeeRepository.GetEmployee(id);

foreach (var entry in data)
{
switch (entry.Key)
{
case "UserId":
Guid userId;
if (Guid.TryParse(entry.Value, out userId))
employeeToUpdate.UserId = userId;
break;
case "SpecializationId":
int specializationId;
if (int.TryParse(entry.Value, out specializationId))
employeeToUpdate.SpecializationId = specializationId;
break;
case "Graduate":
employeeToUpdate.Graduate = entry.Value;
break;
case "Experience":
employeeToUpdate.Experience = entry.Value;
break;
}
}

return EmployeeConverter.EmployeeModelToEmployee(employeeToUpdate);
}

public bool Delete(int id)
{
return _employeeRepository.Delete(new Employee { Id = id, });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using DoctorsHelp.Application.Models;
using DoctorsHelp.Infrastructure.Persistence.Converters;
using DoctorsHelp.Infrastructure.Persistence.Interfaces;
using DoctorsHelp.Infrastructure.Persistence.Repositories;
using Infrastructure.Persistence.Models;

namespace DoctorsHelp.Application.Contracts.Services;

public class ReviewService : IReviewService
{
private readonly IReviewRepository _reviewRepository;
private readonly IAppointmentRepository _appointmentRepository;

public ReviewService(ReviewRepository reviewRepository, AppointmentRepository appointmentRepository)
{
_reviewRepository = reviewRepository;
_appointmentRepository = appointmentRepository;
}

public Review Create(int appointmentId, int? grade, string comment)
{
Appointment appointment = AppointmentConverter.AppointmentModelToAppointment(_appointmentRepository.GetAppointment(appointmentId));

var review = new Review
{
Appointment = appointment,
Grade = grade,
Comment = comment,
};
_reviewRepository.Add(review);
return review;
}

public Review? GetReview(int reviewId)
{
var reviewModel = _reviewRepository.GetReview(reviewId);

return ReviewConverter.ReviewModelToReview(reviewModel);
}

public Review Update(int id, Dictionary<string, string> data)
{
ReviewModel reviewToUpdate = _reviewRepository.GetReview(id);

foreach (var entry in data)
{
switch (entry.Key)
{
case "AppointmentId":
int appointmentId;
if (int.TryParse(entry.Value, out appointmentId))
reviewToUpdate.AppointmentId = appointmentId;
break;
case "Rating":
int grade;
if (int.TryParse(entry.Value, out grade))
reviewToUpdate.Grade = grade;
break;
case "Comment":
reviewToUpdate.Comment = entry.Value;
break;
}
}

return ReviewConverter.ReviewModelToReview(reviewToUpdate);
}

public bool Delete(int id)
{
return _reviewRepository.Delete(new Review { Id = id });
}
}
Loading