Ejemplo n.º 1
0
 int IDAL.AddBusLine(BusLine line)
 {
     line.BusLineID1 = NumbersAreRunning.BusLineID;
     NumbersAreRunning.BusLineID++;
     DataSource.BusLines.Add(line.Clone());
     return(line.BusLineID1);
 }
Ejemplo n.º 2
0
 public void AddLine(BusLine line)
 {
     if (DataSource.ListLines.FirstOrDefault(l => l.BusLineNumber == line.BusLineNumber && l.Area == line.Area) != null)
     {
         throw new ArgumentException("Duplicate BusLine");
     }
     line.Id = DataSource.LineId++;
     DataSource.ListLines.Add(line.Clone());
 }
Ejemplo n.º 3
0
        public BusLine GetLine(int lineId, Areas area)
        {
            BusLine tempLine = DataSource.ListLines.Find(l => l.BusLineNumber == lineId && l.Area == area);

            if (tempLine != null)
            {
                return(tempLine.Clone());
            }
            else
            {
                throw new InexistantLineException(lineId, area, $"There is no line {lineId} in {area}");
            }
        }
Ejemplo n.º 4
0
 public void AddLine(BusLine line)
 {
     if (DataSource.ListLines.FirstOrDefault(l => l.Id == line.Id) != null)
     {
         throw new DuplicateLineException
                   (line.BusLineNumber, line.Area, $"Duplicate line {line.BusLineNumber} in {line.Area}");
     }
     if (line.Id == 0)
     {
         line.Id = DataSource.LineId++;
     }
     DataSource.ListLines.Add(line.Clone());
 }
Ejemplo n.º 5
0
        public BusLine GetLine(int lineId, Areas area)
        {
            BusLine tempLine = DataSource.ListLines.Find(l => l.BusLineNumber == lineId && l.Area == area);

            if (tempLine != null)
            {
                return(tempLine.Clone());
            }
            else
            {
                throw new ArgumentException("There is no line with this number and area" + lineId + area);
            }
        }
Ejemplo n.º 6
0
        public void UpdateLine(BusLine line)
        {
            BusLine tempLine = DataSource.ListLines.Find(l => l.BusLineNumber == line.BusLineNumber && l.Area == line.Area);

            if (tempLine != null)
            {
                line.Id = tempLine.Id;
                DataSource.ListLines.Remove(tempLine);
                DataSource.ListLines.Add(line.Clone());
            }
            else
            {
                throw new ArgumentException("line doesn't exist");
            }
        }
Ejemplo n.º 7
0
        public void UpdateLine(BusLine line)
        {
            BusLine tempLine = DataSource.ListLines.Find(l => l.BusLineNumber == line.BusLineNumber && l.Area == line.Area);

            if (tempLine != null)
            {
                line.Id = tempLine.Id;
                DataSource.ListLines.Remove(tempLine);
                DataSource.ListLines.Add(line.Clone());
            }
            else
            {
                throw new InexistantLineException
                          (line.BusLineNumber, line.Area, $"There is no line {line.BusLineNumber} in {line.Area}");
            }
        }
Ejemplo n.º 8
0
        BusLine IDAL.ReturnBusLine(int numberLineId)
        {
            BusLine busLine = DataSource.BusLines.Find(line => line.BusLineID1 == numberLineId);

            return(busLine.Clone() ?? throw new ExceptionLine(numberLineId, "bad id line - The line not exist in the compny!!!"));
        }
Ejemplo n.º 9
0
        void IDAL.UpdatingBusLine(BusLine line)
        {
            int index = DataSource.BusLines.FindIndex(line1 => line1.BusLineID1 == line.BusLineID1);

            DataSource.BusLines[index] = index == -1 ? throw new ExceptionLine(line.BusLineID1, " bad id line - The BusLine not exist in the compny!!!") : line.Clone();
        }