예제 #1
0
        public Ticket CreateNewTicket(Ticket SpaceTicket)
        {
            if (SpaceTicket.Price <= 0)
            {
                throw new InvalidDataException("The price need to be higher than 0");
            }
            if (SpaceTicket.Description == null)
            {
                throw new InvalidDataException("You need to write some kind of description");
            }
            if (SpaceTicket.Distance <= 0)
            {
                throw new InvalidDataException("The distance should be higher than 0");
            }
            if (SpaceTicket.HowManyTicket <= 0)
            {
                throw new InvalidDataException("Should be more than 0 ticket avaible");
            }
            if (SpaceTicket.planet == null)
            {
                throw new InvalidDataException("You need to choose to which planet");
            }
            if (SpaceTicket.TravelDate == new DateTime())
            {
                throw new InvalidDataException("You need a travel date");
            }

            return(_TicketRepository.CreateNewTicket(SpaceTicket));
        }