I have this big problem and it's that besides being new to programming, it's quite difficult. The subject is the following, I need to apply MVP to a small desktop program that I am developing and for this I need to completely unlink the view layer with the creation of objects. For example, in the following code I have the creation of the db and I have to make an equality, how do I apply interfaces? Thank you very much!
private void btnGuardar_Click(object sender, EventArgs e)
{
using (DataContext db = new DataContext())
{
Paciente obj = pacienteBindingSource.Current as Paciente;
if (obj != null)
{
if (db.Entry<Paciente>(obj).State==System.Data.Entity.EntityState.Detached)
{
db.Set<Paciente>().Attach(obj);
}
if (obj.PacienteID == 0)
{
db.Entry<Paciente>(obj).State = System.Data.Entity.EntityState.Added;
}
else
db.Entry<Paciente>(obj).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
gridPacientes.Refresh();
pControls.Enabled = false;
}
}
}