コード例 #1
0
        public void UpdateLane(Lane laneToUpdateWith)
        {
            //Try getting the lane from the Lanes
            Lane regularLaneToReplace = Lanes.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id);

            if (regularLaneToReplace != null)
            {
                int laneIndex = Lanes.IndexOf(regularLaneToReplace);
                Lanes.RemoveAt(laneIndex);
                Lanes.Insert(laneIndex, laneToUpdateWith);
                return;
            }

            //If none, try getting from Backlog
            Lane backLogLaneToReplace = Backlog.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id);

            if (backLogLaneToReplace != null)
            {
                int laneIndex = Backlog.IndexOf(backLogLaneToReplace);
                Backlog.RemoveAt(laneIndex);
                Backlog.Insert(laneIndex, laneToUpdateWith);
                return;
            }

            //Lastly, get it from Archive
            Lane archiveLaneToReplace = Archive.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id);

            if (archiveLaneToReplace != null)
            {
                int laneIndex = Archive.IndexOf(archiveLaneToReplace);
                Archive.RemoveAt(laneIndex);
                Archive.Insert(laneIndex, laneToUpdateWith);
                return;
            }

            throw new ItemNotFoundException("Could not find the Lane to replace with the updated Lane.");
        }