예제 #1
0
        public IHttpActionResult NearByStadium([FromUri] double lng, [FromUri] double lat, [FromUri] double distance, [FromUri] string keyword)
        {
            var result = new BaseResult();

            result.ResultCode    = "1";
            result.ResultMessage = "Error";
            var            sta    = new StadiumDAL().GetList();
            List <Stadium> nearby = new List <Stadium>();

            if (sta.Any())
            {
                nearby = sta.Where(a => Distance.GetDistance(a.Latitude, a.Longitude, lat, lng) <= distance).ToList();
            }
            if (!keyword.IsNullOrWhiteSpace())
            {
                nearby = nearby.Where(a => a.Name.Contains(keyword) || a.Address.Contains(keyword)).ToList();
            }
            if (nearby.Any())
            {
                result.ResultData = nearby.Select(a => new
                {
                    Id            = a.Id,
                    CreateTime    = a.CreateTime,
                    UpdateTime    = a.UpdateTime,
                    OperationUser = a.OperationUser,
                    Status        = a.Status,
                    Version       = a.Version,
                    Name          = a.Name,
                    Address       = a.Address,
                    OpenStartTime = a.OpenStartTime.HasValue?a.OpenStartTime.Value.ToString("HH:mm"):"",
                    OpenEndTime   = a.OpenEndTime.HasValue ? a.OpenEndTime.Value.ToString("HH:mm") : "",
                    Price         = a.Price,
                    Phone         = a.Phone,
                    Longitude     = a.Longitude,
                    Latitude      = a.Latitude,
                });
                result.ResultMessage = "Success";
                result.ResultCode    = "0";
            }
            else
            {
                result.ResultMessage = "未找到数据";
            }
            return(Ok(result));
        }
예제 #2
0
 public IHttpActionResult NearByStadium([FromUri] double lng, [FromUri] double lat, [FromUri] double distance, [FromUri] string keyword)
 {
     var result = new BaseResult();
     result.ResultCode = "1";
     result.ResultMessage = "Error";
     var sta = new StadiumDAL().GetList();
     List<Stadium> nearby = new List<Stadium>();
     if (sta.Any())
     {
         nearby = sta.Where(a => Distance.GetDistance(a.Latitude, a.Longitude, lat, lng) <= distance).ToList();
     }
     if (!keyword.IsNullOrWhiteSpace())
     {
         nearby = nearby.Where(a => a.Name.Contains(keyword) || a.Address.Contains(keyword)).ToList();
     }
     if (nearby.Any())
     {
         result.ResultData = nearby.Select(a => new
         {
             Id = a.Id,
             CreateTime = a.CreateTime,
             UpdateTime = a.UpdateTime,
             OperationUser = a.OperationUser,
             Status = a.Status,
             Version = a.Version,
             Name = a.Name,
             Address = a.Address,
             OpenStartTime = a.OpenStartTime.HasValue?a.OpenStartTime.Value.ToString("HH:mm"):"",
             OpenEndTime = a.OpenEndTime.HasValue ? a.OpenEndTime.Value.ToString("HH:mm") : "",
             Price = a.Price,
             Phone = a.Phone,
             Longitude = a.Longitude,
             Latitude = a.Latitude,
         });
         result.ResultMessage = "Success";
         result.ResultCode = "0";
     }
     else
     {
         result.ResultMessage = "未找到数据";
     }
     return Ok(result);
 }
예제 #3
0
        public IHttpActionResult KeyWordNearByStadium([FromUri] string key)
        {
            var result = new BaseResult();
            result.ResultCode = "1";
            result.ResultMessage = "Error";
            List<Stadium> nearby = new StadiumDAL().GetListByKeyWord(key);

            if (nearby.Any())
            {
                result.ResultData = nearby;
                result.ResultMessage = "Success";
                result.ResultCode = "0";
            }
            else
            {
                result.ResultMessage = "未找到数据";
            }
            return Ok(result);
        }
예제 #4
0
        public IHttpActionResult KeyWordNearByStadium([FromUri] string key)
        {
            var result = new BaseResult();

            result.ResultCode    = "1";
            result.ResultMessage = "Error";
            List <Stadium> nearby = new StadiumDAL().GetListByKeyWord(key);

            if (nearby.Any())
            {
                result.ResultData    = nearby;
                result.ResultMessage = "Success";
                result.ResultCode    = "0";
            }
            else
            {
                result.ResultMessage = "未找到数据";
            }
            return(Ok(result));
        }