People,
I ask for urgent help ...
I have a system that is running "right". Made in C # (WinForm) and SQL Server (without EntityFramework). However, due to studies and the need to extend the system (adding new features and improving elsewhere) I'm redoing the entire system.
I think I knew OOP and that the system was object oriented. Great innocence on my part.
I am heavily studying OOP and realized the atrocities I committed on my system, so reboot. However, as I'm taking one step at a time and trying to do everything right from the beginning so I do not have to redo again.
Behold, my doubt arose. I'll try to exemplify.
My BLL layer has:
public class PessoaFisica
{
public string Nome { get; private set; }
public Enum.Sexo Sexo { get; private set; }
public DateTime? DataNascimento { get; private set; }
public int? Idade { get; private set; }
public Enum.EstadoCivil EstadoCivil { get; private set; }
public string CPF { get; private set; }
public string DocumentoIdentificacao { get; private set; }
public string Nacionalidade { get; private set; }
public string NacionalidadeComplemento { get; private set; }
public Enum.Estados NaturalidadeEstado { get; private set; }
public string NaturalidadeCidade { get; private set; }
public string Profissao { get; private set; }
public Endereco Endereco { get; private set; }
}
And some classes that inherit from PessoaPhysica, for example, follow one:
public class Genitor : PessoaFisica
{
public Enum.SituacaoGenitor SituacaoGenior { get; private set; }
public Enum.Estados FalecimentoEstado { get; private set; }
public string FalecimentoCidade { get; private set; }
public string FalecimentoData { get; private set; }
public string TempoDesaparecimento { get; private set; }
public bool ApresentaDocIdentificacao { get; private set; } = true;
public bool NecessidadeTestemunha { get; private set; } = false;
public bool Assina { get; private set; } = true;
public bool NecessidadeInterprete { get; private set; } = false;
}
Okay. So far ... I do not think there are any big problems. These classes are reflections of my screens.
I am using Entity Framework (Code First) for communication with the database (SQL Server).
I have, for example, the following entity in EF:
public partial class Genitor
{
public int IdGenitor { get; set; }
public string Tipo { get; set; }
public string Nome { get; set; }
public Nullable<System.DateTime> Nascimento { get; set; }
public Nullable<int> Idade { get; set; }
public string Profissao { get; set; }
public string Nacionalidade { get; set; }
public string NaturalidadeEstado { get; set; }
public string NaturalidadeCidade { get; set; }
public string Falecido { get; set; }
public string DataFalecimento { get; set; }
public string FalecimentoEstado { get; set; }
public string FalecimentoCidade { get; set; }
public Nullable<int> IdUsuario { get; set; }
public string Situacao { get; set; }
public string DocIdentificacao { get; set; }
public string Endereco { get; set; }
public string Cidade { get; set; }
public string Estado { get; set; }
public string TempoDesaparecimento { get; set; }
public string ApresentaDocIdentificacao { get; set; }
public string NecessidadeTestemunha { get; set; }
public string Assina { get; set; }
public string NecessidadeInterprete { get; set; }
public virtual Usuario Usuario { get; set; }
}
Here's my question:
Is it right to have two classes for the "same" thing? How so? Explain: Two classes (one in BLL and one in EF) for Genitor.
In the class that is in the BLL, I have specific data types (Enum, etc.) that are "impossible" in EF.
So how do? Create a layer between BLL and DAL to "map" this? Explaining to the EF entity how the BLL class works? I do not think so ... because that would cause a great coupling.
Or is it okay to just use the EF entities (DAL) for the data ... ie create the Genitor object (EF entity) when you click the button to save the data and send the EF persisting this data?
I do not know if I understood correctly ... but I have this doubt.
I have not found examples of systems to see how this is resolved.
Thanks in advance for your help.