public bool Actualizar(Conductor obj) { if (!String.IsNullOrWhiteSpace(obj.Dni)) { if (conductorRepository.Exists(obj.Dni)) { PersonaRepository personaRepository = new PersonaRepository(); #region PERSONAREPOSITORY //Si tiene DNI, debe tener persona if (!String.IsNullOrWhiteSpace(obj.Dni)) { if (obj.DniNavigation is null)//Si no tiene, la creo { obj.DniNavigation = new Persona() { Dni = obj.Dni, Tipo = "cli" }; } else { obj.DniNavigation.Dni = obj.Dni; obj.DniNavigation.Tipo = "cli"; } if (personaRepository.Exists(obj.DniNavigation.Dni)) { personaRepository.Update(obj.DniNavigation); } else { personaRepository.Insert(obj.DniNavigation); } //Si este cliente tiene representante legal, actualiza, si no tiene, verificar que no exista ya ese cliente para registrarlo } #endregion return(conductorRepository.Update(obj)); } else { throw new Exception(ExceptionMessageManager.ExceptionMessageConductor.DoesNotExist(obj.Dni)); } } else { throw new Exception(ExceptionMessageManager.ExceptionMessageConductor.KeyIsNull()); } }
public static void Update(Conductor obj) { repository.Update(obj); }