37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using MedicalDatabaseContracts;
|
|
using MedicalDatabaseContracts.Models;
|
|
using Microsoft.Extensions.Logging;
|
|
using Npgsql;
|
|
using System.Data;
|
|
|
|
namespace MedicalPostgresqlDatabase.Storages
|
|
{
|
|
public class SpecializationStorage : AbstractPostgresqlStorage<Specialization>
|
|
{
|
|
public SpecializationStorage(ILogger<IStorage<Specialization>> logger) : base(logger, "specializations", "specialization_id", "specializations_id_seq") { }
|
|
|
|
protected override Specialization CreateEntityFromReader(NpgsqlDataReader reader)
|
|
{
|
|
return new Specialization
|
|
{
|
|
Id = Convert.ToInt32(reader.GetValue(PRIMARY_KEY_COLUMN_NAME)),
|
|
Name = Convert.ToString(reader.GetValue("name")),
|
|
IsPediatric = Convert.ToBoolean(reader.GetValue("is_pediatric")),
|
|
IsTherapeutic = Convert.ToBoolean(reader.GetValue("is_therapeutic")),
|
|
};
|
|
}
|
|
|
|
protected override Dictionary<string, string> GetEntityAttributesDictionary(Specialization item)
|
|
{
|
|
var dict = new Dictionary<string, string>
|
|
{
|
|
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
|
{ "name", item.Name },
|
|
{ "is_pediatric", item.IsPediatric.ToString() },
|
|
{ "is_therapeutic", item.IsTherapeutic.ToString() },
|
|
};
|
|
return dict;
|
|
}
|
|
}
|
|
}
|