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