public CharterSchedule Build()
        {
            var schedule = new CharterSchedule("Emirates", "Pride 305", this._flightNo, 5);

            this._timeTables.ForEach(a => schedule.AddTimeTable(a));
            return(schedule);
        }
        public void should_generate_flights_based_on_charter_schedule_when_arrive_is_different_from_depart()
        {
            var schedule = new CharterSchedule("Qatar Airways", "Airbus", "4070", 250);
            var depart1  = TimeSpan.Parse("21:00");
            var arrive1  = TimeSpan.Parse("03:00");

            schedule.AddTimeTable(new CharterTimeTable(DayOfWeek.Monday, "IKA", "HKT", depart1, arrive1));

            var start = DateTime.Parse("2019-08-19");   //Monday
            var end   = DateTime.Parse("2019-08-22");


            var expected = new List <Flight>()
            {
                new Flight()
                {
                    Origin      = "IKA",
                    Destination = "HKT",
                    FlightNo    = "4070",
                    Depart      = DateTime.Parse("2019-08-19 21:00:00"),
                    Arrive      = DateTime.Parse("2019-08-20 03:00:00"),
                },
            };

            var actual = FlightGenerationService.Generate(start, end, schedule);

            actual.Should().BeEquivalentTo(expected);
        }
        public Guid Create(CreateCharterScheduleDto dto)
        {
            var charterSchedule = new CharterSchedule(dto.Airline, dto.Airplane, dto.FlightNo, dto.Seats);

            foreach (var table in dto.TimeTables)
            {
                var depart = TimeSpan.Parse(table.DepartureTime);
                var arrive = TimeSpan.Parse(table.ArriveDate);
                charterSchedule.AddTimeTable(new CharterTimeTable(table.Day, table.Origin, table.Destination, depart, arrive));
            }
            _dbContext.CharterSchedules.Add(charterSchedule);
            _dbContext.SaveChanges();
            return(charterSchedule.Id);
        }