public async Task <string> participantesComunidad(string id, string trimestre)
        {
            try
            {
                double indicador = 0;

                DateTime fechaInicio;
                DateTime fechaTermino;

                switch (trimestre)
                {
                case "1":
                    fechaInicio  = new DateTime(int.Parse(id), 1, 1, 12, 0, 0);
                    fechaTermino = new DateTime(int.Parse(id), 3, 31, 12, 0, 0);
                    break;

                case "2":
                    fechaInicio  = new DateTime(int.Parse(id), 4, 1, 12, 0, 0);
                    fechaTermino = new DateTime(int.Parse(id), 6, 30, 12, 0, 0);
                    break;

                case "3":
                    fechaInicio  = new DateTime(int.Parse(id), 7, 1, 12, 0, 0);
                    fechaTermino = new DateTime(int.Parse(id), 9, 30, 12, 0, 0);
                    break;

                case "4":
                    fechaInicio  = new DateTime(int.Parse(id), 10, 1, 12, 0, 0);
                    fechaTermino = new DateTime(int.Parse(id), 12, 31, 12, 0, 0);
                    break;

                default:
                    fechaInicio  = new DateTime(int.Parse(id), 1, 1, 12, 0, 0);
                    fechaTermino = new DateTime(int.Parse(id), 12, 31, 12, 0, 0);
                    break;
                }

                var           query    = "SELECT DISTINCT idPersonas FROM CP.tab_Miembros where FechaAlta >  convert(date,'" + fechaInicio.ToShortDateString() + "',103) and FechaAlta <  convert(date,'" + fechaTermino.ToShortDateString() + "',103) and estado = 1";
                List <string> miembros = await _db.Database.SqlQuery <string>(query).ToListAsync();

                PersonasRepository rp = new PersonasRepository();
                int personas          = await rp.ContabilizaNoEmpleados();

                string cant1 = miembros.Count().ToString();
                string cant2 = personas.ToString();

                double porcentaje = double.Parse(cant1) / double.Parse(cant2);

                if (porcentaje > 0)
                {
                    indicador = porcentaje * 100;
                }

                return(indicador.ToString());
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task <string> piLicenciadaxInvestigador(string id)
        {
            try
            {
                double indicador = 0;

                DateTime fechaInicio;
                DateTime fechaTermino;

                fechaInicio  = new DateTime(int.Parse(id), 1, 1, 12, 0, 0);
                fechaTermino = new DateTime(int.Parse(id), 12, 31, 12, 0, 0);


                PersonasRepository rp = new PersonasRepository();
                int personas          = await rp.ContabilizaNoEmpleados();

                var propiedadPorPeriodo = await _pictx.PropiedadIndustrial.Where(e => (e.FechaExpedicion > fechaInicio && e.FechaExpedicion < fechaTermino) && e.EsPropiedadInstituto == true).CountAsync();


                string cant1 = propiedadPorPeriodo.ToString();
                string cant2 = personas.ToString();


                double porcentaje = double.Parse(cant1) / double.Parse(cant2);

                if (porcentaje > 0)
                {
                    indicador = porcentaje * 100;
                }



                return(indicador.ToString());
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Example #3
0
        public async Task <string> actualizacionesPeriodo(string id)
        {
            try
            {
                double porcentaje = 0;
                double promedio   = 0;

                PersonasRepository rp = new PersonasRepository();
                int personas          = await rp.ContabilizaNoEmpleados();


                DateTime fechaInicio  = new DateTime(int.Parse(id), 1, 1, 12, 0, 0);
                DateTime fechaTermino = new DateTime(int.Parse(id), 12, 31, 12, 0, 0);

                List <Personas> actualizaciones = await rp.GetAllActualizado(fechaInicio, fechaTermino);



                string cant1 = actualizaciones.Count().ToString();
                string cant2 = personas.ToString();


                porcentaje = double.Parse(cant1) / double.Parse(cant2);

                if (porcentaje > 0)
                {
                    promedio = porcentaje * 100;
                }

                return(promedio.ToString());
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }