public void UpdateItemSortOrder(int sessionId, int codeCampId, int newPosition) { // get the time slots that aren't full span var availableTimeSlots = timeSlotRepo.GetItems(codeCampId).Where(t => !t.SpanAllTracks); // re-order timeslots by time only var timeSlots = TimeSlotInfoController.SortTimeSlots(availableTimeSlots).ToList(); // get the time slot matching the index var slot = timeSlots[newPosition]; // get the session var session = repo.GetItem(sessionId, codeCampId); session.TimeSlotId = slot.TimeSlotId; repo.UpdateItem(session); }