Exemplo n.º 1
0
        /// <summary>
        /// 编辑景点
        /// </summary>
        public void EditViewSpot(AddOrEditViewSpotDto input)
        {
            //using (TransactionScope tran = new TransactionScope())
            //{
            using (var db = new RTDbContext())
            {
                int wisdomGuideId = GetWisdomGuideId(db);
                var model         = db.WisdomGuideViewSpots.FirstOrDefault(p => p.Id == input.Id);
                if (model == null)
                {
                    throw new RTException("所选数据不存在");
                }

                model.ImgUrl = HttpPathCombine(_resourcePath, input.SmallImgUrl);
                //model.ViewSpotDescribe = input.ViewSpotDescribe;
                model.Position        = input.Position;
                model.Phone           = input.Phone;
                model.Longitude       = input.Longitude;
                model.Latitude        = input.Latitude;
                model.ViewSpotName    = input.ViewSpotName;
                model.WisdomGuideId   = wisdomGuideId;
                db.Entry(model).State = EntityState.Modified;

                int ViewSpotId = model.Id;

                _detail.AddOrEdit(new AddOrEditDetailInput
                {
                    ProjectId  = model.Id,
                    ImgUrl     = HttpPathCombine(_resourcePath, input.BigImgUrl),
                    Paragraphs = input.Contents
                }, db);

                var list = db.WisdomGuideViewSpotVideos.Where(p => p.WisdomGuideViewSpotId == ViewSpotId).ToList();
                if (list != null && list.Count() != 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        db.WisdomGuideViewSpotVideos.Remove(list[i]);
                    }
                }

                if (input.VoiceList != null && input.VoiceList.Count != 0)
                {
                    input.VoiceList.ForEach(item =>
                    {
                        db.WisdomGuideViewSpotVideos.Add(new WisdomGuideViewSpotVideo
                        {
                            ImgUrl                = HttpPathCombine(_resourcePath, item.ImgUrl),
                            VoiceName             = item.VoiceName,
                            VoiceUrl              = HttpPathCombine(_voicePath, item.VoiceUrl),
                            WisdomGuideViewSpotId = ViewSpotId
                        });
                    });
                }

                db.SaveChanges();
            }
            //    tran.Complete();
            //}
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加景点
        /// </summary>
        public void AddViewSpot(AddOrEditViewSpotDto input)
        {
            //using (TransactionScope tran = new TransactionScope())
            //{
            using (var db = new RTDbContext())
            {
                int wisdomGuideId = GetWisdomGuideId(db);
                var model         = new WisdomGuideViewSpot
                {
                    //Content = input.Content,
                    ImgUrl = HttpPathCombine(_resourcePath, input.SmallImgUrl),
                    //ViewSpotDescribe = input.ViewSpotDescribe,
                    Position      = input.Position,
                    Phone         = input.Phone,
                    Longitude     = input.Longitude,
                    Latitude      = input.Latitude,
                    ViewSpotName  = input.ViewSpotName,
                    WisdomGuideId = wisdomGuideId
                };
                db.WisdomGuideViewSpots.Add(model);
                db.SaveChanges();


                _detail.AddOrEdit(new AddOrEditDetailInput
                {
                    ProjectId  = model.Id,
                    ImgUrl     = HttpPathCombine(_resourcePath, input.BigImgUrl),
                    Paragraphs = input.Contents
                }, db);

                int ViewSpotId = model.Id;
                if (input.VoiceList != null && input.VoiceList.Count != 0)
                {
                    input.VoiceList.ForEach(item =>
                    {
                        db.WisdomGuideViewSpotVideos.Add(new WisdomGuideViewSpotVideo
                        {
                            ImgUrl                = HttpPathCombine(_resourcePath, item.ImgUrl),
                            VoiceName             = item.VoiceName,
                            VoiceUrl              = HttpPathCombine(_voicePath, item.VoiceUrl),
                            WisdomGuideViewSpotId = ViewSpotId
                        });
                    });
                }
                db.SaveChanges();
            }
            //tran.Complete();
            //}
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加景点
        /// </summary>
        public GeneralResult AddViewSpot(AddOrEditViewSpotDto input)
        {
            var result = new GeneralResult();

            try
            {
                bll.AddViewSpot(input);
                result.State = 0;
                result.Msg   = "操作成功";
            }
            catch (RTException e)
            {
                result = RTExceptionHandle(e);
            }
            catch (Exception e1)
            {
                result = ExceptionHandle(e1);
            }
            return(result);
        }