/// <summary>
 /// 编辑旅游信息
 /// </summary>
 /// <param name="input"></param>
 public void Edit(AddOrEditTouristInformation input)
 {
     using (var db = new RTDbContext())
     {
         var information = db.TouristInformations.FirstOrDefault(p => p.Id == input.Id);
         if (information == null)
         {
             throw new RTException("所选信息不存在");
         }
         information.ImgUrl    = HttpPathCombine(_imgPath, input.SmallImgUrl);
         information.Position  = input.Position;
         information.Longitude = input.Longitude;
         information.Latitude  = input.Latitude;
         information.Name      = input.Name;
         information.Phone     = input.Phone;
         information.Price     = input.Price;
         //information.Distance = input.Distance;
         information.Type            = input.Type;
         db.Entry(information).State = EntityState.Modified;
         db.SaveChanges();
         if (information.Type == TouristInformationType.Hotel || information.Type == TouristInformationType.Winery)
         {
             _detail.AddOrEdit(new AddOrEditDetailInput
             {
                 Classify   = (int)information.Type,
                 ProjectId  = information.Id,
                 ImgUrl     = HttpPathCombine(_imgPath, input.BigImgUrl),
                 Paragraphs = input.Contents
             }, db);
             db.SaveChanges();
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 添加或编辑详情信息
        /// </summary>
        /// <param name="input"></param>
        /// <param name="db"></param>
        public void AddOrEdit(AddOrEditDetailInput input, RTDbContext db)
        {
            var detail   = db.Details.FirstOrDefault(p => p.ModularType == _modularType && p.Classify == input.Classify && p.ProjectId == input.ProjectId);
            var detailId = 0;

            if (detail == null)
            {
                var model = new Detail
                {
                    ModularType = _modularType,
                    Classify    = input.Classify,
                    ProjectId   = input.ProjectId,
                    ImgUrl      = input.ImgUrl
                };
                db.Details.Add(model);
                db.SaveChanges();
                detailId = model.Id;
            }
            else
            {
                detail.ModularType     = _modularType;
                detail.Classify        = input.Classify;
                detail.ProjectId       = input.ProjectId;
                detail.ImgUrl          = input.ImgUrl;
                db.Entry(detail).State = EntityState.Modified;
                detailId = detail.Id;
            }

            //删除原有文章信息
            var list = db.DetailParagraphs.Where(p => p.DetailId == detailId).ToList();

            if (list != null && list.Count() != 0)
            {
                for (int i = 0; i < list.Count(); i++)
                {
                    db.DetailParagraphs.Remove(list[i]);
                }
            }
            if (input.Paragraphs != null && input.Paragraphs.Count != 0)
            {
                int i = 0;
                input.Paragraphs.ForEach(item =>
                {
                    i += 1;
                    db.DetailParagraphs.Add(new DetailParagraph
                    {
                        DetailId         = detailId,
                        ParagraphIndex   = i,
                        ParagraphContent = item
                    });
                });
            }
            db.SaveChanges();
        }
예제 #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();
            //}
        }
예제 #4
0
        /// <summary>
        /// 编辑简介仁怀
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public void Edit(IntroduceInput input)
        {
            var introduceId = 0;
            var model       = new Introduce
            {
                Title = input.Title,
                //VideoUrl= HttpPathCombine(_imgPath,input.VideoUrl)
                VideoUrl = input.VideoUrl
                           //ImgUrl = Path.Combine(imgPath,input.ImgUrl),
                           //Content = input.Content
            };

            //try
            //{
            using (var db = new RTDbContext())
            {
                var oldModel = db.Introduces.FirstOrDefault();
                if (oldModel == null)
                {
                    db.Introduces.Add(model);
                    db.SaveChanges();
                    introduceId = model.Id;
                }
                else
                {
                    oldModel.Title    = model.Title;
                    oldModel.VideoUrl = model.VideoUrl;
                    //oldModel.ImgUrl = model.ImgUrl;
                    //oldModel.Content = model.Content;
                    db.Entry(oldModel).State = EntityState.Modified;
                    db.SaveChanges();
                    introduceId = oldModel.Id;
                }

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

                db.SaveChanges();
            }
            //}
            //catch(Exception e)
            //{
            //    return false;
            //}
        }
예제 #5
0
        /// <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();
            //}
        }
        /// <summary>
        /// Returns the updated Appointment from the database.
        /// </summary>
        public static Appointment GetUpdatedAppointment(Appointment appt)
        {
            using (RTDbContext Context = InitializeDatabaseContext())
            {
                // Because the celestial body is not required, we only want to
                // perform these operations if one is present.
                if (appt.celestial_body_id != null)
                {
                    Context.Entry(appt.CelestialBody).State = EntityState.Unchanged;
                    if (appt.CelestialBody.Coordinate != null)
                    {
                        Context.Entry(appt.CelestialBody.Coordinate).State = EntityState.Unchanged;
                    }
                }
                if (appt.Orientation != null)
                {
                    Context.Entry(appt.Orientation).State = EntityState.Unchanged;
                }
                Context.Entry(appt.SpectraCyberConfig).State = EntityState.Unchanged;
                Context.Entry(appt.Telescope).State          = EntityState.Unchanged;
                Context.Entry(appt.User).State = EntityState.Unchanged;

                Context.SaveChanges();

                Context.Appointments.Attach(appt);

                Context.Entry(appt).Reload();
            }
            return(appt);
        }
예제 #7
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();
            //}
        }
        /// <summary>
        /// 编辑旅游线路信息
        /// </summary>
        /// <param name="input"></param>
        public void Edit(AddOrEditTouristRouteInput input)
        {
            using (var db = new RTDbContext())
            {
                var routes = db.TouristRoutes.FirstOrDefault(p => p.Id == input.Id);
                if (routes == null)
                {
                    throw new RTException("所选数据不存在");
                }
                routes.ImgUrl    = HttpPathCombine(_imgPath, input.ImgUrl);
                routes.NeedDays  = input.NeedDays;
                routes.RouteName = input.RouteName;
                //routes.Content = input.Content;
                db.Entry(routes).State = EntityState.Modified;

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

                db.SaveChanges();
            }
        }
예제 #9
0
        /// <summary>
        /// 获取智慧导览Id
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        private int GetWisdomGuideId(RTDbContext db)
        {
            var wisdomGuide = db.WisdomGuides.FirstOrDefault();

            if (wisdomGuide != null)
            {
                return(wisdomGuide.Id);
            }
            db.WisdomGuides.Add(new WisdomGuide());
            db.SaveChanges();
            return(db.WisdomGuides.FirstOrDefault().Id);
        }
예제 #10
0
 /// <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();
     }
 }
 /// <summary>
 /// 添加旅游信息
 /// </summary>
 /// <param name="input"></param>
 public void Add(AddOrEditTouristInformation input)
 {
     using (var db = new RTDbContext())
     {
         var information = new TouristInformation
         {
             //Distance = input.Distance,
             ImgUrl    = HttpPathCombine(_imgPath, input.SmallImgUrl),
             Position  = input.Position,
             Latitude  = input.Latitude,
             Longitude = input.Longitude,
             Name      = input.Name,
             Phone     = input.Phone,
             Price     = input.Price,
             Type      = input.Type
         };
         db.TouristInformations.Add(information);
         db.SaveChanges();
         if (information.Type == TouristInformationType.Hotel || information.Type == TouristInformationType.Winery)
         {
             //var informationId = information.Id;
             //var detail = new TouristInformationDetail
             //{
             //    InformationId = informationId,
             //    Content = input.Content
             //};
             //db.TouristInformationDetails.Add(detail);
             _detail.AddOrEdit(new AddOrEditDetailInput
             {
                 Classify   = (int)information.Type,
                 ProjectId  = information.Id,
                 ImgUrl     = HttpPathCombine(_imgPath, input.BigImgUrl),
                 Paragraphs = input.Contents
             }, db);
             db.SaveChanges();
         }
     }
 }
        /// <summary>
        /// Creates and stores and RFData reading in the local database.
        /// </summary>
        /// <param name="data">The RFData reading to be created/stored.</param>
        public static void AddRFData(RFData data)
        {
            if (VerifyRFData(data))
            {
                using (RTDbContext Context = InitializeDatabaseContext())
                {
                    // add the rf data to the list in appointment
                    data.Appointment.RFDatas.Add(data);

                    // add the rf data to the database
                    Context.RFDatas.AddOrUpdate(data);

                    Context.Entry(data.Appointment.User).State = EntityState.Unchanged;
                    Context.Entry(data.Appointment).State      = EntityState.Unchanged;
                    if (data.Appointment.Orientation != null)
                    {
                        Context.Entry(data.Appointment.Orientation).State = EntityState.Unchanged;
                    }
                    if (data.Appointment.CelestialBody != null)
                    {
                        if (data.Appointment.CelestialBody.Coordinate != null)
                        {
                            Context.Entry(data.Appointment.CelestialBody.Coordinate).State = EntityState.Unchanged;
                        }
                        Context.Entry(data.Appointment.CelestialBody).State = EntityState.Unchanged;
                    }
                    Context.Entry(data.Appointment.SpectraCyberConfig).State = EntityState.Unchanged;
                    Context.Entry(data.Appointment.Telescope).State          = EntityState.Unchanged;

                    // Only perform the following operations on a real telescope
                    // (i.e. the fields will not be null)
                    if (data.Appointment.Telescope.Location != null)
                    {
                        Context.Entry(data.Appointment.Telescope.Location).State = EntityState.Unchanged;
                    }

                    if (data.Appointment.Telescope.CurrentOrientation != null)
                    {
                        Context.Entry(data.Appointment.Telescope.CurrentOrientation).State = EntityState.Unchanged;
                    }

                    if (data.Appointment.Telescope.CalibrationOrientation != null)
                    {
                        Context.Entry(data.Appointment.Telescope.CalibrationOrientation).State = EntityState.Unchanged;
                    }

                    Context.SaveChanges();
                }
            }
        }
예제 #13
0
        /// <summary>
        /// 添加投诉或建议
        /// </summary>
        /// <param name="input"></param>
        public void Add(AddMessageInput input)
        {
            var model = new Message
            {
                MessageType = input.MessageType,
                Content     = input.Content,
                MessageTime = DateTime.Now
            };

            using (var db = new RTDbContext())
            {
                db.Messages.Add(model);
                db.SaveChanges();
            }
        }
예제 #14
0
        /// <summary>
        /// 添加旅游线路信息
        /// </summary>
        /// <param name="input"></param>
        public void Add(AddOrEditTouristRouteInput input)
        {
            var route = new TouristRoute
            {
                NeedDays  = input.NeedDays,
                RouteName = input.RouteName,
                ImgUrl    = HttpPathCombine(_imgPath, input.ImgUrl)
            };

            using (var db = new RTDbContext())
            {
                db.TouristRoutes.Add(route);
                db.SaveChanges();

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

                db.SaveChanges();
            }
        }
        public JsonResult ListOrder([FromBody] ListingHex listing)
        {
            bool valid = ListingEntry.TryParse(_rpc, _db, listing, out var result, out var error, true);


            //If we got a valid one, mark it as active, and save it to the db
            if (valid)
            {
                result.Active = true;
                //Listings can be updated if they use the same UTXO as a previously uploaded tx
                if (_db.Entry(result)?.State == EntityState.Detached)
                {
                    _db.Listings.Add(result);
                }
                _db.SaveChanges();
            }

            return(new JsonResult(new ListingResult(valid, result, error)));
        }
예제 #16
0
        public void Edit(HomePageInput input)
        {
            var imgPath = ResourcePath.HomePage;
            var model   = new HomePage
            {
                FirstImgUrl = HttpPathCombine(imgPath, input.FirstImgUrl),
                ThirdImgUrl = HttpPathCombine(imgPath, input.ThirdImgUrl)
            };

            if (input.SecondImgUrlList != null && input.SecondImgUrlList.Count != 0)
            {
                input.SecondImgUrlList = input.SecondImgUrlList.Select(p => HttpPathCombine(imgPath, p)).ToList();
                model.SecondImgUrl     = string.Join("\n", input.SecondImgUrlList);
            }
            //try
            //{
            using (var db = new RTDbContext())
            {
                var oldModel = db.HomePages.FirstOrDefault();
                if (oldModel == null)
                {
                    db.HomePages.Add(model);
                }
                else
                {
                    oldModel.FirstImgUrl     = model.FirstImgUrl;
                    oldModel.SecondImgUrl    = model.SecondImgUrl;
                    oldModel.ThirdImgUrl     = model.ThirdImgUrl;
                    db.Entry(oldModel).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
            //}
            //catch(Exception e)
            //{
            //    return false;
            //}
        }
        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();
            }
        }
        /// <summary>
        /// Updates the appointment status by saving the appt passed in.
        /// </summary>
        /// <param name="Context"> The Context that is being saved. </param>
        private static void SaveContext(RTDbContext Context)
        {
            bool saveFailed;

            do
            {
                saveFailed = false;

                try
                {
                    Context.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    // Update the values of the entity that failed to save from the store
                    if (ex.Entries.ToList().Count > 0)
                    {
                        saveFailed = true;
                        ex.Entries.Single().Reload();
                    }
                }
            } while (saveFailed);
        }