/// <summary>
        /// 获取视频列表
        /// </summary>
        public List <ViewSpotVideoDto> GetVideoList(RTEntity <int> input)
        {
            if (input == null)
            {
                throw new RTException("输入参数不能为空");
            }
            var result = new List <ViewSpotVideoDto>();

            using (var db = new RTDbContext())
            {
                var viewPort = db.WisdomGuideViewSpots.FirstOrDefault(p => p.Id == input.Parameter);
                if (viewPort == null)
                {
                    throw new RTException("所选数据不存在");
                }

                var videoList = db.WisdomGuideViewSpotVideos.Where(p => p.WisdomGuideViewSpotId == viewPort.Id).ToList();
                if (videoList != null && videoList.Count != 0)
                {
                    videoList.ForEach(item =>
                    {
                        result.Add(new ViewSpotVideoDto
                        {
                            ImgUrl    = item.ImgUrl,
                            VoiceName = item.VoiceName,
                            VoiceUrl  = item.VoiceUrl,
                        });
                    });
                }
            }
            return(result);
        }
        /// <summary>
        /// 获取景点详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ViewSpotDetailOutput ViewSpotDetail(RTEntity <int> input)
        {
            if (input == null)
            {
                throw new RTException("输入参数不能为空");
            }
            var result = new ViewSpotDetailOutput();

            using (var db = new RTDbContext())
            {
                var viewPort = db.WisdomGuideViewSpots.FirstOrDefault(p => p.Id == input.Parameter);
                if (viewPort == null)
                {
                    throw new RTException("所选数据不存在");
                }

                var detail = _detail.GetDetail(new GetDetailInput
                {
                    ProjectId = viewPort.Id
                }, db);
                if (detail == null)
                {
                    return(result);
                }

                result.BigImgUrl = detail.ImgUrl;
                result.Contents  = detail.Paragraphs;
            }
            return(result);
        }
        /// <summary>
        /// 根据Id获取单个旅游线路信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public TouristRouteForView GetTouristRoute(RTEntity <int> input)
        {
            var result = new TouristRouteForView();

            using (var db = new RTDbContext())
            {
                var route = db.TouristRoutes.FirstOrDefault(p => p.Id == input.Parameter);
                if (route == null)
                {
                    throw new RTException("所选数据不存在");
                }
                result.Id        = route.Id;
                result.ImgUrl    = route.ImgUrl;
                result.NeedDays  = route.NeedDays;
                result.RouteName = route.RouteName;

                var detail = _detail.GetDetail(new GetDetailInput
                {
                    ProjectId = route.Id
                }, db);
                if (detail == null)
                {
                    return(result);
                }
                result.Contents = detail.Paragraphs;
            }
            return(result);
        }
        /// <summary>
        /// 获取用于编辑景点的数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public AddOrEditViewSpotDto GetViewSpotForEdit(RTEntity <int> input)
        {
            if (input == null)
            {
                throw new RTException("输入参数不能为空");
            }
            var result = new AddOrEditViewSpotDto();

            using (var db = new RTDbContext())
            {
                var viewSpot = db.WisdomGuideViewSpots.FirstOrDefault(p => p.Id == input.Parameter);
                if (viewSpot == null)
                {
                    throw new RTException("所选数据不存在");
                }
                result.Id          = viewSpot.Id;
                result.SmallImgUrl = viewSpot.ImgUrl;
                //result.Content = viewSpot.Content;
                //result.ImgUrl = viewSpot.ImgUrl;
                //result.ViewSpotDescribe = viewSpot.ViewSpotDescribe;
                result.Position      = viewSpot.Position;
                result.Phone         = viewSpot.Phone;
                result.Longitude     = viewSpot.Longitude;
                result.Latitude      = viewSpot.Latitude;
                result.ViewSpotName  = viewSpot.ViewSpotName;
                result.WisdomGuideId = viewSpot.WisdomGuideId;

                var detail = _detail.GetDetail(new GetDetailInput
                {
                    ProjectId = viewSpot.Id
                }, db);
                if (detail == null)
                {
                    return(result);
                }

                result.BigImgUrl = detail.ImgUrl;
                result.Contents  = detail.Paragraphs;

                var videoList = db.WisdomGuideViewSpotVideos.Where(p => p.WisdomGuideViewSpotId == viewSpot.Id).ToList();
                if (videoList != null && videoList.Count != 0)
                {
                    result.VoiceList = new List <ViewSpotVideoDto>();
                    videoList.ForEach(item =>
                    {
                        result.VoiceList.Add(new ViewSpotVideoDto
                        {
                            ImgUrl                = item.ImgUrl,
                            VoiceName             = item.VoiceName,
                            VoiceUrl              = item.VoiceUrl,
                            WisdomGuideViewSpotId = item.WisdomGuideViewSpotId
                        });
                    });
                }
            }
            return(result);
        }
 /// <summary>
 /// 根据Id删除旅游线路
 /// </summary>
 /// <param name="input"></param>
 public void Delete(RTEntity <int> input)
 {
     using (var db = new RTDbContext())
     {
         var route = db.TouristRoutes.FirstOrDefault(p => p.Id == input.Parameter);
         if (route == null)
         {
             throw new RTException("所删数据不存在");
         }
         db.TouristRoutes.Remove(route);
         db.SaveChanges();
     }
 }
示例#6
0
        public GeneralResult GetVideoList(RTEntity <int> input)
        {
            var result = new GeneralResult();

            try
            {
                result.Data  = bll.GetVideoList(input);
                result.State = 0;
                result.Msg   = "操作成功";
            }
            catch (RTException e)
            {
                result = RTExceptionHandle(e);
            }
            catch (Exception e1)
            {
                result = ExceptionHandle(e1);
            }
            return(result);
        }
        public GeneralResult Delete(RTEntity <int> input)
        {
            var result = new GeneralResult();

            try
            {
                bll.Delete(input);
                result.State = 0;
                result.Msg   = "操作成功";
            }
            catch (RTException e)
            {
                result = RTExceptionHandle(e);
            }
            catch (Exception e1)
            {
                result = ExceptionHandle(e1);
            }
            return(result);
        }
        /// <summary>
        /// 获取旅游信息用于编辑
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public AddOrEditTouristInformation GetInformationForEdit(RTEntity <int> input)
        {
            var result = new AddOrEditTouristInformation();

            using (var db = new RTDbContext())
            {
                var information = db.TouristInformations.FirstOrDefault(p => p.Id == input.Parameter);
                if (information == null)
                {
                    throw new RTException("所选数据不存在");
                }
                //result.Distance = information.Distance;
                result.Id          = information.Id;
                result.SmallImgUrl = information.ImgUrl;
                result.Position    = information.Position;
                result.Longitude   = information.Longitude;
                result.Latitude    = information.Latitude;
                result.Name        = information.Name;
                result.Phone       = information.Phone;
                result.Price       = information.Price;
                result.Type        = information.Type;
                if (result.Type == TouristInformationType.Hotel || information.Type == TouristInformationType.Winery)
                {
                    var detail = _detail.GetDetail(new GetDetailInput
                    {
                        Classify  = (int)result.Type,
                        ProjectId = information.Id
                    }, db);
                    if (detail == null)
                    {
                        return(result);
                    }

                    result.BigImgUrl = detail.ImgUrl;
                    result.Contents  = detail.Paragraphs;
                }
            }
            return(result);
        }
        public void Delete(RTEntity <int> input)
        {
            using (var db = new RTDbContext())
            {
                var information = db.TouristInformations.FirstOrDefault();
                if (information == null)
                {
                    throw new RTException("所删数据不存在");
                }
                //var detail = db.TouristInformationDetails.FirstOrDefault(p => p.InformationId == information.Id);
                //db.TouristInformationDetails.Remove(detail);

                //删除详情
                _detail.Delete(new GetDetailInput
                {
                    Classify  = (int)information.Type,
                    ProjectId = information.Id
                }, db);

                db.TouristInformations.Remove(information);
                db.SaveChanges();
            }
        }