Exemple #1
0
        public string Execute(string[] data)
        {
            int    tripId = int.Parse(data[0]);
            string status = data[1];

            if (!tripService.Exists(tripId))
            {
                return(TripNotFound);
            }


            return(tripService.ChangeTripStatus(tripId, status));
        }
        public string Execute(string[] data)
        {
            var ticketDto = new TicketDto
            {
                CustomerId = int.Parse(data[0]),
                TripId     = int.Parse(data[1]),
                Price      = decimal.Parse(data[2]),
                Seat       = data[3]
            };


            if (!Validation.Validation.IsValid(ticketDto))
            {
                return(InvalidArgs);
            }


            if (!customerService.Exists(ticketDto.CustomerId))
            {
                return(CustomerNotFound);
            }

            if (!tripService.Exists(ticketDto.TripId))
            {
                return(TripNotFound);
            }

            if (!customerService.HasEnoughMoney(ticketDto.CustomerId, ticketDto.Price))
            {
                return(NotEnoughMoney);
            }

            customerService.PayTicket(ticketDto.CustomerId, ticketDto.Price);

            return(ticketService.BuyTicket(ticketDto.CustomerId, ticketDto.TripId, ticketDto.Price, ticketDto.Seat));
        }