Правка по хранилищам
This commit is contained in:
parent
54da29877b
commit
f827ae1915
@ -27,7 +27,7 @@ namespace MedicalPostgresqlDatabase
|
||||
|
||||
protected abstract T CreateEntityFromReader(NpgsqlDataReader reader);
|
||||
|
||||
protected abstract Dictionary<string, string> GetEntityAttributesDictionary(T item);
|
||||
protected abstract Dictionary<string, object> GetEntityAttributesDictionary(T item);
|
||||
|
||||
public virtual void Delete(int id)
|
||||
{
|
||||
@ -54,8 +54,8 @@ namespace MedicalPostgresqlDatabase
|
||||
{
|
||||
using var connection = GetConnection();
|
||||
connection.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM {TABLE_NAME} WHERE {PRIMARY_KEY_COLUMN_NAME} = @{PRIMARY_KEY_COLUMN_NAME}", connection);
|
||||
cmd.Parameters.AddWithValue($"@{PRIMARY_KEY_COLUMN_NAME}", id);
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM {TABLE_NAME} WHERE {PRIMARY_KEY_COLUMN_NAME} = @id", connection);
|
||||
cmd.Parameters.AddWithValue($"@id", id);
|
||||
_logger.LogDebug(cmd.CommandText);
|
||||
Stopwatch stopwatch = new();
|
||||
stopwatch.Start();
|
||||
@ -167,14 +167,7 @@ namespace MedicalPostgresqlDatabase
|
||||
|
||||
foreach (var key in dict.Keys)
|
||||
{
|
||||
if (key == PRIMARY_KEY_COLUMN_NAME)
|
||||
{
|
||||
cmd.Parameters.AddWithValue($"@{key}", Convert.ToInt32(dict[key]));
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue($"@{key}", dict[key]);
|
||||
}
|
||||
cmd.Parameters.AddWithValue($"@{key}", dict[key]);
|
||||
}
|
||||
|
||||
_logger.LogDebug(cmd.CommandText);
|
||||
|
@ -18,11 +18,11 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
};
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetEntityAttributesDictionary(Diagnose item)
|
||||
protected override Dictionary<string, object> GetEntityAttributesDictionary(Diagnose item)
|
||||
{
|
||||
var dict = new Dictionary<string, string>
|
||||
var dict = new Dictionary<string, object>
|
||||
{
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id },
|
||||
{ "name", item.Name },
|
||||
};
|
||||
return dict;
|
||||
|
@ -22,16 +22,16 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
};
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetEntityAttributesDictionary(Doctor item)
|
||||
protected override Dictionary<string, object> GetEntityAttributesDictionary(Doctor item)
|
||||
{
|
||||
var dict = new Dictionary<string, string>
|
||||
var dict = new Dictionary<string, object>
|
||||
{
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id },
|
||||
{ "name", item.Name },
|
||||
{ "surname", item.Surname },
|
||||
{ "patronymic", item.Patronymic },
|
||||
{ "patronymic", item.Patronymic ?? string.Empty },
|
||||
{ "phone_number", item.PhoneNumber },
|
||||
{ "specialization_id", item.SpecializationId.ToString() }
|
||||
{ "specialization_id", item.SpecializationId }
|
||||
};
|
||||
return dict;
|
||||
}
|
||||
|
@ -25,19 +25,19 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
};
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetEntityAttributesDictionary(Patient item)
|
||||
protected override Dictionary<string, object> GetEntityAttributesDictionary(Patient item)
|
||||
{
|
||||
var dict = new Dictionary<string, string>
|
||||
var dict = new Dictionary<string, object>
|
||||
{
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id },
|
||||
{ "name", item.Name },
|
||||
{ "surname", item.Surname },
|
||||
{ "patronymic", item.Patronymic },
|
||||
{ "patronymic", item.Patronymic ?? string.Empty },
|
||||
{ "phone_number", item.PhoneNumber },
|
||||
{ "gender", item.Gender.ToString() },
|
||||
{ "birthday", item.Birthday.ToString() },
|
||||
{ "weight", item.Weight.ToString() },
|
||||
{ "height", item.Height.ToString() },
|
||||
{ "gender", item.Gender },
|
||||
{ "birthday", item.Birthday },
|
||||
{ "weight", item.Weight },
|
||||
{ "height", item.Height },
|
||||
};
|
||||
return dict;
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
};
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetEntityAttributesDictionary(Specialization item)
|
||||
protected override Dictionary<string, object> GetEntityAttributesDictionary(Specialization item)
|
||||
{
|
||||
var dict = new Dictionary<string, string>
|
||||
var dict = new Dictionary<string, object>
|
||||
{
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id },
|
||||
{ "name", item.Name },
|
||||
{ "is_pediatric", item.IsPediatric.ToString() },
|
||||
{ "is_therapeutic", item.IsTherapeutic.ToString() },
|
||||
{ "is_pediatric", item.IsPediatric },
|
||||
{ "is_therapeutic", item.IsTherapeutic },
|
||||
};
|
||||
return dict;
|
||||
}
|
||||
|
@ -24,17 +24,17 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
};
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetEntityAttributesDictionary(Visit item)
|
||||
protected override Dictionary<string, object> GetEntityAttributesDictionary(Visit item)
|
||||
{
|
||||
var dict = new Dictionary<string, string>
|
||||
var dict = new Dictionary<string, object>
|
||||
{
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
||||
{ "patient_id", item.PatientId.ToString() },
|
||||
{ "doctor_id", item.DoctorId.ToString() },
|
||||
{ "diagnose_id", item.DiagnoseId.ToString() },
|
||||
{ "comment", item.Comment ?? string.Empty },
|
||||
{ "date", item.Date.ToString() },
|
||||
{ "time", item.Time.ToString() },
|
||||
{ PRIMARY_KEY_COLUMN_NAME, item.Id },
|
||||
{ "patient_id", item.PatientId },
|
||||
{ "doctor_id", item.DoctorId },
|
||||
{ "diagnose_id", item.DiagnoseId },
|
||||
{ "comment", item.Comment },
|
||||
{ "date", item.Date },
|
||||
{ "time", item.Time },
|
||||
};
|
||||
return dict;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user