コード例 #1
0
ファイル: TripService.cs プロジェクト: clarionprogrammer/CASM
        public void ReorderWaypoints(Trip trip, int wpId, int newOrder)
        {
            var changingWaypoints = trip.Waypoints.Where(w => w.Id != wpId);
            var originalOrder = trip.Waypoints.FirstOrDefault(w => w.Id == wpId).Order;

            // Handle New Order Out Of Range
            if (newOrder > trip.Waypoints.Max(w => w.Order))
                newOrder = trip.Waypoints.Max(w => w.Order);

            // Set order of waypoint in question
            trip.Waypoints.FirstOrDefault(w => w.Id == wpId).Order = newOrder;

            ReorderTopGap(newOrder, changingWaypoints, originalOrder);
            ReorderBottomGap(newOrder, changingWaypoints, originalOrder);
        }
コード例 #2
0
        public ActionResult QuickAdd(TripQuickAddViewModel vm)
        {
            var trip = new Trip
            {
                StatusId = 1,
                AirplaneId = vm.AirplaneId,
                Name = vm.TripName,
                Waypoints = new Collection<Waypoint>()
            };
            trip.Waypoints.Add(QuickAddDepartingWaypoint(vm));
            trip.Waypoints.Add(QuickAddArrivingWaypoint(vm));
            tripRepository.InsertOrUpdate(trip);
            tripRepository.CommitChanges();

            return JsonResult(new { Success = true, trip });
        }