Exemplo n.º 1
0
        public void Execute(string[] data)
        {
            int tripId;

            if (!int.TryParse(data[0], out tripId))
            {
                throw new ArgumentException($"{tripId} is not a valid input for trip id!");
            }

            Status status;

            if (!Enum.TryParse(data[1], out status))
            {
                throw new ArgumentException($"{data[1]} is not a valid input status!");
            }

            if (!infoService.TripExists(tripId))
            {
                throw new ArgumentException($"No trip with id({tripId}) was found!");
            }

            if (infoService.TripHasSameStatus(tripId, status))
            {
                throw new InvalidOperationException($"Trip with id({tripId}) is already marked as {status}");
            }

            tripService.ChangeStatus(tripId, status);
        }