namespace DocuMed.Repository.Handlers.Hospitals;

public class CreateHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<CreateHospitalCommand, Guid>
{

    public async Task<Guid> Handle(CreateHospitalCommand request, CancellationToken cancellationToken)
    {
        var ent = Hospital.Create(request.Name, request.Detail, request.Address, request.UniversityId);

        repositoryWrapper.SetRepository<Hospital>().Add(ent);
        await repositoryWrapper.SaveChangesAsync(cancellationToken);

        return ent.Id;

    }
}