/// <summary> /// Método que devuelve un registro Email concreto. /// </summary> /// <param name="id"> identificador a buscar en la tabla Emails.</param> /// <returns>Devuelve un objeto EmailData o null si no lo encuentra.</returns> public EmailData getEmailId(int id) { try { using (GestionEmpresasEntities db = new GestionEmpresasEntities()) { var resulta = from mail in db.Email where mail.idEmail == id select mail; foreach (Email co in resulta) { EmailData correoData = new EmailData() { EmailID = co.idEmail, Correo = co.correo }; return correoData; } return null; } } catch (SqlException ex) { FaultException fault = new FaultException("EError SQL" + ex.Message, new FaultCode("SQL")); throw fault; } catch (Exception ex) { throw new FaultException(ex.Message, new FaultCode("ERROR SERVICIO LISTADO DE EMAILS")); } }
/*************************************************************** *******************************FIN EMAIL-EMPRESA**************** ***************************************************************/ /*************************************************************** ******************************* EMAIL-CONTACTO******************** ***************************************************************/ public List<EmailData> getEmailContacto(int idContacto) { List<EmailData> list = new List<EmailData>(); EmailData mail; try { using (GestionEmpresasEntities db = new GestionEmpresasEntities()) { var resulta = from cont in db.Contacto where cont.idContacto == idContacto select cont; Contacto contResult = resulta.First(); foreach (Email em in contResult.Email) { mail = new EmailData(); mail.EmailID = em.idEmail; mail.Correo = em.correo; list.Add(mail); } return list; } } catch (SqlException ex) { FaultException fault = new FaultException("EError SQL" + ex.Message, new FaultCode("SQL")); throw fault; } catch (Exception ex) { throw new FaultException(ex.Message, new FaultCode("ERROR SERVICIO LISTADO DE EMAILS")); } }
/*************************************************************** *******************************FIN EMPRESA********************** ***************************************************************/ /*************************************************************** ******************************* EMAIL-EMPRESA******************** ***************************************************************/ /// <summary> /// Método que devuelve todos los emails de una empresa en concreto. /// </summary> /// <param name="idEmpresa">Identificador de la empresa de la que queremos listar sus emails</param> /// <returns>Devuelve una lista de emails de una empresa en concreto.</returns> public List<EmailData> getEmailEmpresa(int idEmpresa) { List<EmailData> list = new List<EmailData>(); EmailData email; try { using (GestionEmpresasEntities db = new GestionEmpresasEntities()) { var resulta = from empresa in db.Empresa where empresa.idEmpresa == idEmpresa select empresa; Empresa empresaResult = resulta.First(); foreach (Email em in empresaResult.Email) { email = new EmailData(); email.EmailID = em.idEmail; email.Correo = em.correo; list.Add(email); } return list; } } catch (SqlException ex) { FaultException fault = new FaultException("EError SQL" + ex.Message, new FaultCode("SQL")); throw fault; } catch (Exception ex) { throw new FaultException(ex.Message, new FaultCode("ERROR SERVICIO LISTADO DE EMAILS")); } }
/// <summary> /// Método que obtiene todos los emails contenidos en la tabla Email /// </summary> /// <returns>Devuelve una lista de objetos Email.</returns> public List<EmailData> getAllEmail() { List<EmailData> datos = new List<EmailData>(); try { using (GestionEmpresasEntities db = new GestionEmpresasEntities()) { var resulta = from email in db.Email select email; foreach (Email co in resulta) { EmailData correoData = new EmailData() { EmailID = co.idEmail, Correo = co.correo }; datos.Add(correoData); } return datos; } } catch (SqlException ex) { FaultException fault = new FaultException("EError SQL" + ex.Message, new FaultCode("SQL")); throw fault; } catch (Exception ex) { throw new FaultException(ex.Message, new FaultCode("ERROR SERVICIO LISTADO DE EMAILS")); } }