Example #1
0
        public bool ValidarDatosDemandante(Demandante emp)
        {
            //if (!String.IsNullOrEmpty(emp.NombreEmpresa) && !String.IsNullOrEmpty(emp.Direccion) &&
            //    emp.NumeroEmpleados != null && emp.IdUsuario != null && emp.TipoIndustria != null)
            //{
            UTDemandante utDemandante = new UTDemandante();

            return(utDemandante.GuardarDatosDemandante(emp));
            //}
            //return false;
        }
        /// <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);
        }
        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);
        }
        /// <summary>
        /// obtiene el perfil de un demandante - /demandante/{dni}
        /// </summary>
        /// <param name="Dni"></param>
        /// <returns>MultipleDemandanteDniGet</returns>
        public IHttpActionResult Get([FromUri] string Dni)
        {
            // TODO: implement Get - route: demandante/{dni}
            // var result = new MultipleDemandanteDniGet();
            // return Ok(result);
            MultipleDemandanteDniGet resp       = new MultipleDemandanteDniGet();
            MySqlConnection          connection = null;

            try
            {
                connection = new MySqlConnection("host=localhost; port=3306; user=usuario; password=; database=mtis_final");
                connection.Open();
                MySqlCommand command = new MySqlCommand();
                command.Connection  = connection;
                command.CommandText = "SELECT * FROM demandante WHERE dni=@dni";
                command.Prepare();
                command.Parameters.AddWithValue("@dni", Dni);
                MySqlDataReader resultSet  = command.ExecuteReader();
                Demandante      demandante = new Demandante();

                if (resultSet.Read())
                {
                    demandante.Dni               = resultSet[1].ToString();
                    demandante.Pass              = resultSet[2].ToString();
                    demandante.Nombre            = resultSet[3].ToString();
                    demandante.Apellidos         = resultSet[4].ToString();
                    demandante.Direccion         = resultSet[5].ToString();
                    demandante.Poblacion         = resultSet[6].ToString();
                    demandante.Telefono          = resultSet[7].ToString();
                    demandante.Email             = resultSet[8].ToString();
                    demandante.Fecha_nacimiento  = resultSet[9].ToString();
                    demandante.Fecha_renovacion  = resultSet[10].ToString();
                    demandante.Iban              = resultSet[11].ToString();
                    demandante.Situacion_laboral = (bool)resultSet[12] ? "true" : "false";
                    demandante.Edad              = resultSet[13].ToString(); //(int)resultSet[13];
                    demandante.Titulos           = resultSet[14].ToString();
                    demandante.Experiencia       = resultSet[15].ToString(); //(int)resultSet[15];


                    resp.Demandante = demandante;
                    resultSet.Close();
                    return(Ok(resp.Demandante));
                }

                else
                {
                    resp.ErrorDemandante         = new ErrorDemandante();
                    resp.ErrorDemandante.Codigo  = 404;
                    resp.ErrorDemandante.Mensaje = "No se encuentra el demandante con ese DNI";
                    return(Content(System.Net.HttpStatusCode.NotFound, resp.ErrorDemandante));
                }
            }

            catch (Exception e)
            {
                return(InternalServerError());//   Content(System.Net.HttpStatusCode.InternalServerError);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }