public ActionResult Create(String telefonoFijo, String telefonoCelular, String cedulaJuridica, String correo, string nombre_cliente, string username, string password, String telefonoFijo2, String telefonoCelular2, String correo2, String nombreCompleto, string cedula) { try { InformacionContacto informacionContacto = new InformacionContacto(correo, telefonoFijo, telefonoCelular); Cliente cliente = new Cliente(nombre_cliente, username, password); InformacionContacto informacionContactoResponsable = new InformacionContacto(correo2, telefonoFijo2, telefonoCelular2); ResponsableLegal responsableLegal = new ResponsableLegal(nombreCompleto, cedula, informacionContactoResponsable); responsableLegal.InformacionContacto = informacionContactoResponsable; Entidad entidad = new Entidad(); entidad.CedulaJuridica = cedulaJuridica; entidad.Cliente = cliente; entidad.ResponsableLegal = responsableLegal; entidad.InformacionContacto = informacionContacto; entidadDao.insertarEntidad(entidad); correoDao.generarCorreo(correo, username, password, nombreCompleto); return(RedirectToAction("Index")); } catch (MySqlException ex) { return(RedirectToAction("Error", "Entidad")); } }
public List <Entidad> getAllEntidades() { List <Entidad> list = new List <Entidad>(); using (MySqlConnection sqlCon = GetConnection()) { sqlCon.Open(); String query = "Select e.id_entidad, e.id_cliente,e.cedulaJuridica,e.idResponsable_legal, e.id_informacion_contacto, i.correo,i.telefonoFijo,i.telefonoCelular, c.nombre_completo, c.username, c.password, e.idResponsable_legal,r.idResponsable_legal , r.nombreCompleto, r.cedula, r.id_informacion_contacto,ir.id_informacion_contacto AS id_informacion_contactoResponsable, ir.correo AS correoResponsable,ir.telefonoFijo AS telefonoFijoResponsable,ir.telefonoCelular AS telefonoCelularResponsable, r.idResponsable_legal from " + "informacion_contacto ir,entidad e, informacion_contacto i, cliente c, responsable_legal r where e.id_informacion_contacto= i.id_informacion_contacto and c.id_cliente= e.id_cliente and e.idResponsable_legal = r.idResponsable_legal and r.id_informacion_contacto =ir.id_informacion_contacto;"; MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon); using (MySqlDataReader reader = sqlSelect.ExecuteReader()) { Entidad entidad = null; InformacionContacto informacionContacto = null; Cliente cliente = null; ResponsableLegal responsableLegal = null; while (reader.Read()) { entidad = new Entidad(); entidad.IdEntidad = reader.GetInt32("id_entidad"); entidad.CedulaJuridica = reader.GetString("cedulaJuridica"); informacionContacto = new InformacionContacto(); informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto"); informacionContacto.Correo = reader.GetString("correo"); informacionContacto.TelefonoFijo = reader.GetString("telefonoFijo"); informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular"); cliente = new Cliente(); cliente.IdCliente = reader.GetInt32("id_cliente"); cliente.Nombre_cliente = reader.GetString("nombre_completo"); cliente.Username = reader.GetString("username"); cliente.Password = reader.GetString("password"); responsableLegal = new ResponsableLegal(); responsableLegal.Cedula = reader.GetString("cedula"); responsableLegal.NombreCompleto = reader.GetString("nombreCompleto"); responsableLegal.IdReponsableLegal = reader.GetInt32("idResponsable_legal"); responsableLegal.InformacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contactoResponsable"); responsableLegal.InformacionContacto.Correo = reader.GetString("correoResponsable"); responsableLegal.InformacionContacto.TelefonoFijo = reader.GetString("telefonoFijoResponsable"); responsableLegal.InformacionContacto.TelefonoCelular = reader.GetString("telefonoCelularResponsable"); entidad.InformacionContacto = informacionContacto; entidad.Cliente = cliente; entidad.ResponsableLegal = responsableLegal; list.Add(entidad); } sqlCon.Close(); } } return(list); }