-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MindCare_Central_Clinic.Controllers | ||
{ | ||
public class PatientController : Controller | ||
{ | ||
private readonly ILogger<PatientController> _logger; | ||
|
||
public PatientController(ILogger<PatientController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public IActionResult Index() | ||
{ | ||
|
||
|
||
return View(); | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using MySql.Data.MySqlClient; | ||
using System.Data; | ||
using System.Data.Common; | ||
using System.Data.Entity.Infrastructure; | ||
|
||
namespace MindCare.Application.DataAccess.DbContext | ||
{ | ||
public class DbConnectionFactory : IDbConnectionFactory | ||
{ | ||
private readonly IConfiguration _configuration; | ||
|
||
|
||
public DbConnectionFactory(IConfiguration configuration) => _configuration = configuration; | ||
|
||
public DbContext ObterContexto(string AppSettingsSection) | ||
{ | ||
IConfigurationSection configuracaoSessao = _configuration.GetSection(AppSettingsSection); | ||
AppSettingsDbConfiguracao configSessao = new(); | ||
configuracaoSessao.Bind(configSessao); | ||
|
||
IDbConnection dbConnection; | ||
ISQLCommands sqlCommands; | ||
ISQLQuerys sqlQuerys; | ||
|
||
switch (configSessao.TipoBanco) | ||
{ | ||
case EnumDbConnection.MySQL: | ||
dbConnection = new MySqlConnection(configSessao.ConnectionString); | ||
sqlQuerys = new MySQLQuerys(); | ||
sqlCommands = new MySQLCommands(); | ||
break; | ||
default: | ||
throw new NotImplementedException(); | ||
} | ||
|
||
return new DbContext(dbConnection, sqlQuerys, sqlCommands); | ||
} | ||
} | ||
|
||
public enum EnumDbConnection | ||
{ | ||
SQL, | ||
MySQL, | ||
Oracle, | ||
PhpMyAdmin | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using MySql.Data.MySqlClient; | ||
using System.Data.SqlClient; | ||
using System.Data; | ||
|
||
namespace MindCare.Application.DataAccess.DbContext | ||
{ | ||
public class DbContext | ||
{ | ||
public IDbConnection connection; | ||
public ISQLQuerys sqlQuery; | ||
public ISQLCommands sqlCommand; | ||
public DbContext(IDbConnection connection, ISQLQuerys siapQuery, ISQLCommands siapCommand) | ||
{ | ||
this.connection = connection ?? throw new ArgumentNullException(nameof(DbContext.connection)); | ||
this.sqlQuery = siapQuery ?? throw new ArgumentNullException(nameof(sqlQuery)); | ||
this.sqlCommand = siapCommand ?? throw new ArgumentNullException(nameof(sqlCommand)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace MindCare.Application.DataAccess.DbContext | ||
{ | ||
public interface IDbContext | ||
{ | ||
public string Initialize(DbConnType conn); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using MindCare.Application.DataAccess.DbContext; | ||
using MindCare.Application.Entities; | ||
using System.Data.Common; | ||
|
||
namespace MindCare.Application.DataAccess.Repository | ||
{ | ||
public class PatientRepository | ||
{ | ||
private readonly IDbContext _dbContext; | ||
private readonly DbConnection _connection; | ||
|
||
public PatientRepository(IDbContext dbContext) | ||
{ | ||
_dbContext = dbContext.Initialize(); | ||
} | ||
|
||
public async IEnumerable<Patient> Select(Patient obj) | ||
{ | ||
var newObj = | ||
Check failure on line 19 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
Check failure on line 19 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
Check failure on line 19 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
|
||
return await | ||
Check failure on line 20 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
Check failure on line 20 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
Check failure on line 20 in MindCare.Application/DataAccess/Repository/PatientRepository.cs GitHub Actions / build
|
||
} | ||
} | ||
} |