/// <summary>
 /// Este metodo convierte un DAL a DTO
 /// </summary>
 /// <param name="DAL">Parametro DAL</param>
 /// <returns>Objeto tipo DTO</returns>
 public static MunicipioDTO MapeoDALToDTO(Municipio DAL)
 {
     try
     {
         MunicipioDTO c = new MunicipioDTO();
         c.Nombre      = DAL.Nombre;
         c.MunicipioId = DAL.MunicipioId;
         if (DAL.Departamento != null)
         {
             c.Departamento = Departamento.MapeoDALToDTO(DAL.Departamento);
         }
         return(c);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 /// <summary>
 /// Este metodo convierte un DTO a DAL
 /// </summary>
 /// <param name="DTO">Parametro DTO</param>
 /// <returns>Objeto tipo DAL</returns>
 public static Municipio MapeoDTOToDAL(MunicipioDTO DTO)
 {
     try
     {
         Municipio c = new Municipio();
         c.Nombre      = DTO.Nombre;
         c.MunicipioId = DTO.MunicipioId;
         if (DTO.Departamento != null)
         {
             c.Departamento = Departamento.MapeoDTOToDAL(DTO.Departamento);
         }
         return(c);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 /// <summary>
 /// Este metodo convierte un DAL a DTO
 /// </summary>
 /// <param name="DAL">Parametro DTO</param>
 /// <returns>Objeto tipo DAL</returns>
 public static PersonaDTO MapeoDALToDTO(Persona DAL)
 {
     try
     {
         PersonaDTO c = new PersonaDTO();
         c.Apellidos      = DAL.Apellidos;
         c.Direccion      = DAL.Direccion;
         c.Identificacion = DAL.Identificacion;
         c.Nombres        = DAL.Nombres;
         c.PersonaId      = DAL.PersonaId;
         c.Sexo           = DAL.Sexo;
         c.Telefono       = DAL.Telefono;
         c.UpdateAt       = DAL.UpdateAt;
         c.CreatedAt      = DAL.CreatedAt;
         c.TipoPersonaId  = DAL.TipoPersonaId;
         if (c.TipoPersona != null)
         {
             c.TipoPersona = TipoPersona.MapeoDALToDTO(DAL.TipoPersona);
         }
         c.Nacionalidad        = DAL.Nacionalidad;
         c.PaisNacimiento      = DAL.PaisNacimiento;
         c.PaisCorrespondencia = DAL.PaisCorrespondencia;
         c.Departamento        = DAL.Departamento;
         if (DAL.Municipio != null)
         {
             c.Municipio = Municipio.MapeoDALToDTO(DAL.Municipio);
         }
         if (DAL.Pais != null)
         {
             c.Pais = Pais.MapeoDALToDTO(DAL.Pais);
         }
         c.MunicipioId     = DAL.MunicipioId;
         c.PaisId          = DAL.PaisId;
         c.Email           = DAL.Email;
         c.FechaNacimiento = DAL.FechaNacimiento;
         return(c);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #4
0
        public void modificaMunicipio(Municipio _municipio)
        {
            var command = new SqlCommand("SP_modificaMunicipio", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idMunicipio", _municipio.idMunicipio);
            command.Parameters.AddWithValue("@idEstado", _municipio.idEstado);
            command.Parameters.AddWithValue("@cNombre", _municipio.Nombre);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
Exemple #5
0
        public int InsertaMunicipio(Municipio _municipio)
        {
            var command = new SqlCommand("dbo.usp_CreaMunicipio", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idEstado", _municipio.idEstado);
            command.Parameters.AddWithValue("@cNombre", _municipio.Nombre);

            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Municipio> obtenerMunicipio(int _idEstado)
        {
            List <Municipio> list = new List <Municipio>();

            Municipio cat;

            try
            {
                var command = new SqlCommand("dbo.usp_ConsultaMunicipio", ConexionSingleton.abrirConexion());
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@idEstado", _idEstado);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    cat                   = new Municipio();
                    cat.idMunicipio       = (int)reader["idMunicipio"];
                    cat.idEstado          = (int)reader["idEstado"];
                    cat.Nombre            = (string)reader["Nombre"];
                    cat.FechaCreacion     = (DateTime)reader["FechaCreacion"];
                    cat.FechaModificacion = (DateTime)reader["FechaModificacion"];
                    list.Add(cat);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQl Error en obtener los datos de municipio" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Code Error en obtener los datos de municipio" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();

            return(list);
        }