/// <summary>
        /// 修改地图地址
        /// </summary>
        public void ChangeMap(ChangeMapInput input)
        {
            if (input.ImgUrl == null || input.ImgUrl == "")
            {
                throw new RTException("请填写图片地址");
            }
            input.ImgUrl = HttpPathCombine(_resourcePath, input.ImgUrl);
            //using (TransactionScope tran = new TransactionScope())
            //{
            using (var db = new RTDbContext())
            {
                int wisdomGuideId = GetWisdomGuideId(db);

                var map = db.WisdomGuideMaps.FirstOrDefault();
                if (map != null)
                {
                    map.WisdomGuideId   = wisdomGuideId;
                    map.ImgUrl          = input.ImgUrl;
                    db.Entry(map).State = EntityState.Modified;
                }
                else
                {
                    db.WisdomGuideMaps.Add(new WisdomGuideMap
                    {
                        WisdomGuideId = wisdomGuideId,
                        ImgUrl        = input.ImgUrl
                    });
                }
                db.SaveChanges();
            }
            //    tran.Complete();
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// 修改地图地址
        /// </summary>
        public GeneralResult ChangeMap(ChangeMapInput input)
        {
            var result = new GeneralResult();

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