コード例 #1
0
 public async ValueTask AddTouristRouteAsync(TouristRoute route)
 {
     if (route == null)
     {
         throw new ArgumentNullException(nameof(route));
     }
     await _context.TouristRoutes.AddAsync(route);
 }
コード例 #2
0
 public void AddTouristRoute(TouristRoute touristRoute)
 {
     if (touristRoute == null)
     {
         throw new ArgumentNullException(nameof(touristRoute));
     }
     _context.TouristRoutes.Add(touristRoute);
 }
コード例 #3
0
 public void AddTouristRoute(TouristRoute touristRoute)
 {
     if (touristRoute == null)
     {
         throw new ArgumentException(nameof(touristRoute));
     }
     _context.TouristRoutes.Add(touristRoute);
     //_context.SaveChanges();
 }
コード例 #4
0
        // 1.判断数据是否合法
        // 2.将新数据保存在上下文关系对象中
        // 3.把数据写入数据库
        public void AddTouristRoute(TouristRoute touristRoute)
        {
            // 1.判断数据是否合法
            if (touristRoute == null)
            {
                throw new ArgumentNullException(nameof(touristRoute));
            }

            // 2.将新数据保存在上下文关系对象中
            _context.TouristRoutes.Add(touristRoute);
        }
コード例 #5
0
        public async Task <IActionResult> DeleteTouristRoute([FromRoute] Guid touristRouteId)
        {
            if (!(await _touristRouteRepository.TouristRouteExistAsync(touristRouteId)))
            {
                return(NotFound("旅游路线找不到"));
            }

            TouristRoute touristRoute = await _touristRouteRepository.GetTouristRouteAsync(touristRouteId);

            _touristRouteRepository.DeleteTouristRoute(touristRoute);
            await _touristRouteRepository.SaveAsync();

            return(NoContent());
        }
コード例 #6
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();
            }
        }
コード例 #7
0
 public void DeleteTouristRoute(TouristRoute touristRoute)
 {
     _context.TouristRoutes.Remove(touristRoute);
 }
コード例 #8
0
 public void AddTouristRoute(TouristRoute touristRoute)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 public void UpdateTouristRoute(TouristRoute route)
 {
     // no code in this implementation
 }