/// <summary> /// Allows queues to be formed at the specified lane, the attendant to be assigned must have no designated lane /// </summary> /// <param name="queueLaneNumber"></param> /// <param name="attendant"></param> /// <param name="tolerance">Maximum amount of time to consider priority numbers</param> /// <returns></returns> public bool SetLaneActive(int queueLaneNumber, QueueAttendant attendant, TimeSpan tolerance) { //check if the lane queue is existing if (laneQueues.TryGetValue(queueLaneNumber, out LaneQueue laneQueue)) { //allow only attendants that do not have a designated lane if (attendant.DesignatedLane.LaneNumber != 0 || attendant.DesignatedLane.LaneName != null) { return(false); } //get the associated lane to the lane number var lane = dataAccessLogic.GetLaneWithLaneNumber( queueLaneNumber ); laneQueue = new LaneQueue(); laneQueue.SetQueueLane(lane); laneQueue.SetAttendant(attendant); laneQueue.Tolerance = tolerance; bool isSuccess = dataAccessLogic.AddLaneQueue( laneQueue ); laneQueue = dataAccessLogic.GetLaneQueueWithLaneID( lane.LaneID ); if (isSuccess && laneQueue == null) { //unexpected error throw new Exception("Failed to get lane queue of lane number: " + queueLaneNumber); } if (isSuccess) { //reflect changes in application laneQueues[queueLaneNumber] = laneQueue; } //conditions for failure: // lane queue already exists for this lane number // the attendant object given does not have an id set return(isSuccess); } else { //lane number unused return(false); } }