Example #1
0
        public static List <ResultModel> GetTopFive()
        {
            SqlConnection oConn = new SqlConnection();

            oConn.ConnectionString = @"Data Source=MIKEW8\TFTIC2012;Initial Catalog=PokWarVelDb;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            List <ResultModel> lm = new List <Models.ResultModel>();

            try
            {
                string     query = "Select Top 5 idHero, avg(eval) as eval from EvalHero group by idHero order by avg(eval) desc";
                SqlCommand oCmd  = new SqlCommand(query, oConn);
                oConn.Open();
                SqlDataReader oDr = oCmd.ExecuteReader();
                while (oDr.Read())
                {
                    MarvelApi.MarvelRequester requester = new MarvelApi.MarvelRequester();

                    lm.Add(Mapper.FromMarvelToLocal(requester.GetCharacter((long)oDr["idHero"])));
                }
            }
            catch (Exception ex)
            { }

            return(lm);
        }
Example #2
0
        private static ResultModel GetOneMarvel(long id)
        {
            MarvelApi.MarvelRequester requester = new MarvelApi.MarvelRequester();
            ResultModel rm = Mapper.FromMarvelToLocal(requester.GetCharacter(id));

            rm.Eval = (int)Math.Round(getAverage(id));

            return(rm);
        }
Example #3
0
        public static List <JsonGeoModel> GetTopFiveWithLoc()
        {
            SqlConnection oConn = new SqlConnection();

            oConn.ConnectionString = @"Data Source=MIKEW8\TFTIC2012;Initial Catalog=PokWarVelDb;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            List <JsonGeoModel> lm = new List <Models.JsonGeoModel>();

            try
            {
                string     query = @"SELECT TOP (5) EvalHero.idHero, AVG(EvalHero.eval) AS eval, LocHero.Long, LocHero.Lat
                                 FROM EvalHero INNER JOIN
                                 LocHero ON EvalHero.idHero = LocHero.idHero
                                 GROUP BY EvalHero.idHero, LocHero.Long, LocHero.Lat
                                 ORDER BY eval DESC";
                SqlCommand oCmd  = new SqlCommand(query, oConn);
                oConn.Open();
                SqlDataReader oDr = oCmd.ExecuteReader();
                while (oDr.Read())
                {
                    MarvelApi.MarvelRequester requester = new MarvelApi.MarvelRequester();

                    Characters c = requester.GetCharacter((long)oDr["idHero"]);

                    JsonGeoModel Jm = new Models.JsonGeoModel()
                    {
                        Id        = c.id,
                        PlaceName = c.name,
                        GeoLat    = (Double)oDr["Lat"],
                        GeoLong   = (Double)oDr["Long"],
                        Avatar    = c.ptiAvatar
                    };

                    lm.Add(Jm);
                }

                return(lm);
            }
            catch (Exception ex)
            { }

            return(lm);
        }
Example #4
0
        private static ResultModel GetOneMarvel(long id)
        {
            MarvelApi.MarvelRequester requester = new MarvelApi.MarvelRequester();

            return(Mapper.FromMarvelToLocal(requester.GetCharacter(id)));
        }