Пример #1
0
        public IHttpActionResult getgymsbydisc([FromBody] getdata data)
        {
            try
            {
                MultigymEntities1 context = new MultigymEntities1();
                List <MG_Gym>     gyms    = new List <MG_Gym>();
                if (data.iddisc == 0)
                {
                    gyms = (from x in context.MG_Gym
                            where x.Activo.Equals(true) &&
                            x.Id_TipoEntidad == (int)tipoEntidad.gymnasio
                            select x).ToList();
                }
                else
                {
                    gyms = (from x in context.MG_Gym_Disc
                            where x.Id_Disciplina == data.iddisc &&
                            x.MG_Gym.Activo.Equals(true)
                            select x.MG_Gym).ToList();
                }

                List <EGym> lista = new List <EGym>();
                foreach (var g in gyms)
                {
                    var gy = new EGym();
                    gy.idgym         = g.ID;
                    gy.nombregym     = g.Nombre;
                    gy.img           = g.ImgLogo;
                    gy.direccion     = g.Direccion;
                    gy.telefono      = g.Telefono;
                    gy.creditos      = g.Creditos;
                    gy.lat           = g.Lat.ToString();
                    gy.lon           = g.Lon.ToString();
                    gy.horariolv     = g.HorarioLV;
                    gy.horarios      = g.HorarioS;
                    gy.horariod      = g.HorarioDF;
                    gy.reviewaverage = g.ReviewAverage.ToString();
                    gy.reviewcount   = g.ReviewCount.ToString();
                    lista.Add(gy);
                }
                return(Ok(RespuestaApi <List <EGym> > .createRespuestaSuccess(lista)));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.Message)));
            }
        }
Пример #2
0
        public IHttpActionResult getgymbynombre([FromBody] getdata data)
        {
            try
            {
                MultigymEntities1 context = new MultigymEntities1();
                List <MG_Gym>     gyms    = new List <MG_Gym>();
                gyms = (from x in context.MG_Gym
                        where x.Activo == true &&
                        x.Nombre.Contains(data.nombregym)
                        select x).ToList();

                List <EGym> lista = new List <EGym>();
                foreach (var g in gyms)
                {
                    var gy = new EGym();
                    gy.idgym         = g.ID;
                    gy.nombregym     = g.Nombre;
                    gy.img           = g.ImgLogo;
                    gy.direccion     = g.Direccion;
                    gy.telefono      = g.Telefono;
                    gy.creditos      = g.Creditos;
                    gy.lat           = g.Lat.ToString();
                    gy.lon           = g.Lon.ToString();
                    gy.horariolv     = g.HorarioLV;
                    gy.horarios      = g.HorarioS;
                    gy.horariod      = g.HorarioDF;
                    gy.reviewaverage = g.ReviewAverage.ToString();
                    gy.reviewcount   = g.ReviewCount.ToString();
                    lista.Add(gy);
                }
                return(Ok(RespuestaApi <List <EGym> > .createRespuestaSuccess(lista)));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.Message)));
            }
        }
Пример #3
0
 public IHttpActionResult gym([FromBody] getdata data)
 {
     try
     {
         MultigymEntities1 context = new MultigymEntities1();
         var res = (from x in context.MG_Gym
                    where x.ID == data.idgym
                    select x).First();
         var result = new EGym();
         result.nombregym = res.Nombre;
         result.img       = res.ImgLogo;
         result.creditos  = res.Creditos;
         result.direccion = res.Direccion;
         result.telefono  = res.Telefono;
         result.horariolv = res.HorarioLV;
         result.horarios  = res.HorarioS;
         result.horariod  = res.HorarioDF;
         return(Ok(RespuestaApi <EGym> .createRespuestaSuccess(result)));
     }
     catch (Exception ex)
     {
         return(Ok(RespuestaApi <string> .createRespuestaError(ex.Message)));
     }
 }
Пример #4
0
        public IHttpActionResult getgymbynombrefiltro([FromBody] getdata data)
        {
            try
            {
                MultigymEntities1 context = new MultigymEntities1();
                List <MG_Gym>     gyms    = new List <MG_Gym>();
                gyms = (from x in context.MG_Gym
                        where x.Activo == true
                        select x).ToList();
                if (!string.IsNullOrEmpty(data.nombregym))
                {
                    gyms = (from x in gyms
                            where x.Nombre.Contains(data.nombregym)
                            select x).ToList();
                }

                if (!string.IsNullOrEmpty(data.fcreditos.ToString()) && data.fcreditos != 0)
                {
                    gyms = (from x in gyms
                            where x.Creditos <= data.fcreditos
                            select x).ToList();
                }

                if (!string.IsNullOrEmpty(data.fcategoria.ToString()) && data.fcategoria != 0)
                {
                    gyms = (from x in gyms
                            where x.MG_Gym_Disc.Any(y => y.Id_Disciplina == data.fcategoria)
                            select x).ToList();
                }


                if (!string.IsNullOrEmpty(data.fcalificacion.ToString()) && data.fcalificacion != 0)
                {
                    gyms = (from x in gyms
                            where (int)x.ReviewAverage >= data.fcalificacion
                            select x).ToList();
                }

                if (!string.IsNullOrEmpty(data.fciudad.ToString()) && data.fciudad != 0)
                {
                    gyms = (from x in gyms
                            where x.Id_Ciudad == data.fciudad
                            select x).ToList();
                }


                List <EGym> lista = new List <EGym>();
                foreach (var g in gyms)
                {
                    var    control  = false;
                    double distance = -1;
                    if (!string.IsNullOrEmpty(data.fdistancia.ToString()) && data.fdistancia != 0)
                    {
                        if (!string.IsNullOrEmpty(data.lat) && !string.IsNullOrEmpty(data.lon))
                        {
                            double latD = ConvertCoordStrToDouble(g.Lat.ToString());
                            double lngD = ConvertCoordStrToDouble(g.Lon.ToString());
                            distance = GetDistance(ConvertCoordStrToDouble(data.lat), ConvertCoordStrToDouble(data.lon), latD, lngD);
                        }
                        else
                        {
                            control = true;
                        }
                    }
                    else
                    {
                        control = true;
                    }
                    if (distance <= (data.fdistancia * 1000) && distance != -1)
                    {
                        control = true;
                    }
                    if (control == true)
                    {
                        var gy = new EGym();
                        gy.idgym         = g.ID;
                        gy.nombregym     = g.Nombre;
                        gy.img           = g.ImgLogo;
                        gy.direccion     = g.Direccion;
                        gy.telefono      = g.Telefono;
                        gy.creditos      = g.Creditos;
                        gy.lat           = g.Lat.ToString();
                        gy.lon           = g.Lon.ToString();
                        gy.horariolv     = g.HorarioLV;
                        gy.horarios      = g.HorarioS;
                        gy.distancia     = distance.ToString();
                        gy.horariod      = g.HorarioDF;
                        gy.reviewaverage = g.ReviewAverage.ToString();
                        gy.reviewcount   = g.ReviewCount.ToString();
                        lista.Add(gy);
                    }
                }
                return(Ok(RespuestaApi <List <EGym> > .createRespuestaSuccess(lista)));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.Message)));
            }
        }