Пример #1
0
        public DemandanteModel GetDemandanteModelByUserId(int id)
        {
            SqlConnection dbCon = new SqlConnection("Data Source=PRODUCCION;Initial Catalog=Prueba;Persist Security Info=True;User ID=sa;Password=Nivelsql*55");

            GestorBD.Repositorio  repositorio = new GestorBD.Repositorio(dbCon);
            dtsLecturaDemandantes dts         = new dtsLecturaDemandantes();
            string sql = "SELECT d.*, u.Usuario, u.Nombre, u.Apellido1, u.Apellido2, u.TipoUsuario, e.Nombre TipoIndustriaNombre FROM Demandantes d INNER JOIN Usuarios u ON d.IdUsuario = u.Id INNER JOIN Estudios e ON d.NivelEstudios = e.NivelEstudios WHERE d.IdUsuario = @idUsuario";

            SqlParameter    param    = new SqlParameter("@idUsuario", id);
            DemandanteModel demModel = new DemandanteModel();

            dts.Merge(repositorio.Leer(sql, CommandType.Text, "Demandantes", param));


            if (dts.Demandantes.Rows.Count > 0)
            {
                demModel = MappingLecturaDemandante.ToDemandanteModel(dts.Demandantes, 0);
                return(demModel);
            }
            else
            {
                demModel = null;
                return(demModel);
            }
        }
Пример #2
0
        /// <summary>
        ///  Comprueba que los datos del Demandante sean válidos y en caso de serlo llama al UTDemandante para guardar sus datos.
        /// </summary>
        /// <param name="emp"></param>
        /// <returns>Devuelve un booleano dependiendo de si los datos son válidos, o de la llamada a UTDemandante.</returns>
        public bool ValidarDatosDemandante(DemandanteModel demModel)
        {
            if (!String.IsNullOrEmpty(demModel.ExperienciaLaboral) && !String.IsNullOrEmpty(demModel.ImagenB64))
            {
                int aux               = 0;
                var typeEdad          = demModel.Edad.GetType();
                var typeIdUsuario     = demModel.IdUsuario.GetType();
                var typeNivelEstudios = demModel.NivelEstudios.GetType();

                if (typeEdad.IsEquivalentTo(aux.GetType()) && typeIdUsuario.IsEquivalentTo(aux.GetType()) && typeNivelEstudios.IsEquivalentTo(aux.GetType()))
                {
                    if (demModel.ImagenB64 == null)
                    {
                        demModel.FotoPerfil = new byte[0];
                    }
                    else
                    {
                        demModel.ImagenB64  = demModel.ImagenB64.Replace("data:image/jpeg;base64,", "");
                        demModel.FotoPerfil = Convert.FromBase64String(demModel.ImagenB64);
                    }

                    return(_UTDemandante.GuardarDatosDemandante(demModel));
                }
            }
            return(false);
        }
Пример #3
0
        /// <summary>
        ///  Realiza una llamada a UTDemandante para obtener un objeto DemandanteModel a partir de una id ofrecida por parámetro.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Devuelve un objeto DemandanteModel</returns>
        public DemandanteModel GetDemandanteModelByUserId(int id)
        {
            DemandanteModel demModel = _UTDemandante.GetDemandanteModelByUserId(id);

            demModel.ImagenB64 = Convert.ToBase64String(demModel.FotoPerfil);

            return(demModel);
        }
Пример #4
0
        /// <summary>
        ///  Obtiene un objeto DemandanteModel (llamando al procedimiento 'pDemandantesLectura') a partir de una id ofrecida por parámetro.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Devuelve un objeto DemandanteModel</returns>
        public DemandanteModel GetDemandanteModelByUserId(int id)
        {
            dtsLecturaDemandantes dts   = new dtsLecturaDemandantes();
            SqlParameter          param = new SqlParameter("@idUsuario", id);

            dts.Merge(this.Repo.Leer("pDemandantesLectura", CommandType.StoredProcedure, dts.Demandantes.TableName, param));
            DemandanteModel demModel = dts.Demandantes.ToDemandanteModel();

            if (dts.Demandantes.Rows.Count > 0)
            {
                return(demModel);
            }
            return(null);
        }
Пример #5
0
        public bool ValidarDatosModificarDemandante(DemandanteModel demModel)
        {
            if (demModel.ImagenB64 == null)
            {
                demModel.FotoPerfil = new byte[0];
            }
            else
            {
                demModel.ImagenB64  = demModel.ImagenB64.Replace("data:image/jpeg;base64,", "");
                demModel.FotoPerfil = Convert.FromBase64String(demModel.ImagenB64);
            }

            return(_UTDemandante.ModificarDatosDemandante(demModel));
        }
Пример #6
0
        public JsonResult ModificarDatosDemandante(DemandanteModel demModel)
        {
            if (ModelState.IsValid)
            {
                NGDemandante ngDemandante = new NGDemandante();
                demModel.IdUsuario = Convert.ToInt32(Cookies.GetCookie("Id"));

                bool result = ngDemandante.ValidarDatosModificarDemandante(demModel);

                if (result)
                {
                    return(Json(demModel));
                }
                return(Json(false));
            }
            return(Json(false));
        }
Пример #7
0
        /// <summary>
        ///  Registra en la base de datos los datos del Demandante ofrecido por parámetro.
        /// </summary>
        /// <param name="dem"></param>
        /// <returns>Devuelve un booleano según si se ha realizado correctamente o no.</returns>
        public bool GuardarDatosDemandante(DemandanteModel dem)
        {
            Demandante aux = GetDemandanteByUserId(dem.IdUsuario);

            if (aux != null)
            {
                return(false);
            }

            dtsDemandantes dts = MappingDemandante.ToDtsDemandantes(dem);

            Repo.Guardar(dts);

            Dictionary <DataColumn, Object> parametros = new Dictionary <DataColumn, object>();

            parametros.Add(dts.Demandantes.IdUsuarioColumn, dem.IdUsuario);

            return(Repo.Count(dts.Demandantes, parametros) == 1);
        }
Пример #8
0
        public bool ModificarDatosUsuario(DemandanteModel demModel)
        {
            Demandante aux = GetDemandanteByUserId(demModel.IdUsuario);

            if (aux == null)
            {
                return(false);
            }

            dtsUsuarios dts = MappingDemandante.ToDtsUsuarioModificar(demModel);

            Repo.Guardar(dts);

            Dictionary <DataColumn, Object> parametros = new Dictionary <DataColumn, object>();

            parametros.Add(dts.Usuarios.IdColumn, demModel.IdUsuario);

            return(true);
        }
        public List <DemandanteModel> GetDemandantesInscritosOferta(int idOferta)
        {
            dtsLecturaDemandantes dts   = new dtsLecturaDemandantes();
            SqlParameter          param = new SqlParameter("@idOferta", idOferta);

            dts.Merge(this.Repo.Leer("pDemandanteModelInscrito", CommandType.StoredProcedure, dts.Demandantes.TableName, param));
            List <DemandanteModel> result = new List <DemandanteModel>();

            int i = 0;

            foreach (DataRow dtRow in dts.Demandantes)
            {
                DemandanteModel demModel = new DemandanteModel();
                demModel = MappingLecturaDemandante.ToDemandanteModelVistaAdmin(dts.Demandantes, i);

                result.Add(demModel);
                i++;
            }
            return(result);
        }
Пример #10
0
 public bool ValidarDatosModificarUsuario(DemandanteModel demModel)
 {
     return(_UTDemandante.ModificarDatosUsuario(demModel));
 }