/// <summary> /// 获取旅游信息列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public List <InformationForView> GetList(GetInformationListInput input) { var result = new List <InformationForView>(); using (var db = new RTDbContext()) { var list = db.TouristInformations.Where(p => p.Type == input.Type); if (list != null && list.Count() != 0) { foreach (var item in list) { double distance = 0; string distanceDescription = ""; if (item.Type == TouristInformationType.Hotel || item.Type == TouristInformationType.Winery) { distance = LongitudeAndLatitudeToDistance.GetDistance(input.Longitude, input.Latitude, item.Longitude, item.Latitude); if (distance > 1000) { distanceDescription = string.Format("距我{0}km", (distance / 1000).ToString("f2")); } else { distanceDescription = string.Format("距我{0}m", distance.ToString("f0")); } } result.Add(new InformationForView { Id = item.Id, //Distance = item.Distance, SmallImgUrl = item.ImgUrl, Name = item.Name, Phone = item.Phone, Price = item.Price, Distance = distance, DistanceDescription = distanceDescription, Position = item.Position, }); } if (input.Type == TouristInformationType.Hotel) { result = result.OrderBy(p => p.Distance).ToList(); } } } return(result); }
public GeneralResult GetList(GetInformationListInput input) { var result = new GeneralResult(); try { result.Data = bll.GetList(input); result.State = 0; result.Msg = "操作成功"; } catch (RTException e) { result = RTExceptionHandle(e); } catch (Exception e1) { result = ExceptionHandle(e1); } return(result); }