Esempio n. 1
0
        public async Task ClubLogbookContextTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                var          membersVar = _context.Members;
                List <Pilot> members    = await _context.Members.ToListAsync();


                List <Club> list2 = await _context.Clubs.Include(a => a.Members).ThenInclude(a => a.Contact).ToListAsync();

                List <Club> list = await _context.Clubs.Include(a => a.Aircrafts).ThenInclude(a => a.AirCraftModel).ToListAsync();

                var cl    = list.FirstOrDefault();
                var list1 = await _context.Clubs.ToListAsync();

                ContactBook contactBooks = await _context.ContactBooks.Include(i => i.Contacts).ThenInclude(ii => ii.Addresses).SingleOrDefaultAsync();

                contactBooks = await _context.ContactBooks.Include(i => i.Contacts).ThenInclude(ii => ii.Phones).SingleOrDefaultAsync();

                List <Address> addresses = contactBooks.Contacts.SelectMany(i => i.Addresses).ToList();
                List <Phone>   phones    = contactBooks.Contacts.SelectMany(i => i.Phones).ToList();
                var            clmem     = cl.Members;

                //cl.Members = members;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        public async Task ClubServiceAircrafFlightTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                cr       = new ClubRepository(_context);
                AircraftLogBookRepository acr = new AircraftLogBookRepository(_context);
                FlightRepository          fr  = new FlightRepository(_context);
                MemberRepository          mr  = new MemberRepository(_context);
                AircraftRepository        ar  = new AircraftRepository(_context);
                ClubService clubService       = new ClubService(cr, mr, fr, ar, acr, null);
                int         aircraftId        = 8;

                ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId);

                var group = flights.GroupBy(o => o.Pilot);
                foreach (var g in group)
                {
                    System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName);
                    foreach (var gi in g)
                    {
                        System.Diagnostics.Debug.WriteLine(gi.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 3
0
        public async Task FlighRecordServiceTest()
        {
            ImportDataTest import = new ImportDataTest();

            _context = import._context;
            //IFlightRecordViewModelService _flightRecordViewModelService = new FlightRecordViewModelService();
        }
Esempio n. 4
0
        public async Task LBRepositoryTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();

            try
            {
                _context          = import._context;
                logbookRepository = new LogbookRepository(_context);

                logbookService = new LogbookService(logbookRepository, null, null);
                IEnumerable <FlightRecord> fr = await logbookService.GetRecordByAircrafAsync(12, 8);

                foreach (var f in fr)
                {
                    System.Diagnostics.Debug.WriteLine(f.ToString());
                }

                LogBook logBook = await logbookRepository.GetByIdWithItemsAsync(1);

                LogBook logBook1 = await logbookRepository.GetFlightRecordsByPilotIdAsync(12);

                LogBook a = await logbookService.GetLogbookByPilotAsync(12);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
 public void Setup()
 {
     //var dbOptions = new DbContextOptionsBuilder<ClubLogbookContext>()
     //   .UseInMemoryDatabase(databaseName: "TestCatalog")
     //   .Options;
     //context = new ClubLogbookContext(dbOptions);
     context = ImportDataTest.InitInMemoryContext();
 }
Esempio n. 6
0
        public async Task PilotRepositoryTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                EFRepository <Pilot> eFRepository = new EFRepository <Pilot>(_context);
                var pilots = await eFRepository.ListAllAsync();

                System.Diagnostics.Debug.WriteLine($"{pilots.Count}");
                foreach (var p in pilots)
                {
                    IMember  member   = p.GetBase().Get();
                    UserInfo userInfo = new UserInfo(p);
                    string   str      = userInfo.GetJason();
                    UserInfo userInfo1;
                    //userInfo1 = str.GetFromJason<UserInfo>();
                    System.Diagnostics.Debug.WriteLine(p.FirstName);
                }
                IAsyncRepository <Pilot> asyncRepositoryPilot = new EFRepository <Pilot>(_context);
                PilotWithSpeciification  spec = new PilotWithSpeciification(0, pilots.Count, null, "g", "");
                var pilot = await asyncRepositoryPilot.ListAsync(spec);

                System.Diagnostics.Debug.WriteLine($"{pilot.Count} {spec.ToString()}");
                foreach (var p in pilot)
                {
                    System.Diagnostics.Debug.WriteLine($"{p.ToString()}");
                }
                spec  = new PilotWithSpeciification(0, pilots.Count, null, "y", "05982");
                pilot = await asyncRepositoryPilot.ListAsync(spec);

                System.Diagnostics.Debug.WriteLine($"{pilot.Count} {spec.ToString()}");
                foreach (var p in pilot)
                {
                    System.Diagnostics.Debug.WriteLine($"{p.ToString()}");
                }
                var p1 = await asyncRepositoryPilot.GetByIdAsync(12);

                System.Diagnostics.Debug.WriteLine($"GetByIdAsync : {p1?.ToString()}");
                var count = await asyncRepositoryPilot.CountAsync(spec);

                System.Diagnostics.Debug.WriteLine($"CountAsync:{count}");
                pilot = await asyncRepositoryPilot.ListAllAsync();

                System.Diagnostics.Debug.WriteLine($"ListAllAsync: {pilot.Count} {spec.ToString()}");
                foreach (var p in pilot)
                {
                    System.Diagnostics.Debug.WriteLine($"{p.ToString()}");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
        public async Task ClubContactsViewModelServiceTest()
        {
            autoMapper = AutoMapperConstructor.Instance.Mapper;
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                MemberRepository mr = new MemberRepository(_context);
                MemberService    ms = new MemberService(mr);
                FlightRepository fr = new FlightRepository(_context);

                ClubRepository cr = new ClubRepository(_context);

                ClubService clubService = new ClubService(cr, mr, fr, null, null, null);
                //ICollection<Pilot> clubBaz = await clubService.GetClubMembers("BAZ");

                autoMapper = AutoMapperConstructor.Instance.Mapper;

                ClubContactsViewModelService clubContactsViewModelService = new ClubContactsViewModelService(clubService, ms, autoMapper);
                //IEnumerable<ClubContactsViewModel> clubContacs = await  clubContactsViewModelService.GetOrCreateClubContact("Baz");
                //cl.Members = members;
                //var p = clubContacs.Where(i => i.IdNumber == "059828392").FirstOrDefault();
                ClubContactsModel clubContactUpdate = new ClubContactsModel();
                Contact           contact           = new Contact();
                contact.Addresses.Add(new Address()
                {
                    City = "Gilon", Country = "Israel", State = "IL", Zipcode = "2010300", Street = "Ofir 60", Type = ContactType.HOME
                });

                contact.EMAILs.Add(new EMAIL()
                {
                    EMail = "*****@*****.**", Type = ContactType.WORK
                });
                contact.Phones.Add(new Phone()
                {
                    PhoneNumber = "05490777553", Type = ContactType.HOME
                });
                clubContactUpdate.DateOfBirth = DateTime.Now;

                //var members = await clubService.GetClubMembers("BAZ");
                await clubContactsViewModelService.UpdateOrCreateClubContactMember("BAZ", clubContactUpdate);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return;
        }
Esempio n. 8
0
        public async Task ClubServiceTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                IReservationRepository reservationRepository = new ReservationRepository(_context);
                cr = new ReservationService(reservationRepository);
                AircraftReservation ar = new AircraftReservation();
                ar.DateFrom   = DateTime.Now;
                ar.DateTo     = DateTime.Now.AddHours(1);
                ar.TailNumber = "4xCGC";
                ar.IdNumber   = "123456";
                _context.AircraftReservations.Add(ar);
                _context.SaveChanges();
                var reser = await cr.GetReservation();

                await cr.AddReservation(ar);

                ar.IdNumber = "098765";
                await cr.EditReservation(ar);

                reser = await cr.GetAircraftReservation(ar.TailNumber);

                var aa = await cr.AddReservation(ar);

                AircraftReservation ab = new AircraftReservation();
                ab.DateFrom   = ar.DateTo;
                ab.DateTo     = ab.DateFrom.AddHours(5);
                ab.TailNumber = ar.TailNumber;
                aa            = await cr.AddReservation(ab);

                reser = await cr.GetReservation();

                reser = await cr.GetPilotReservation(ar.IdNumber);

                await cr.DeleteReservation(ar.Id);

                reser = await cr.GetReservation();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 9
0
        public async Task ClubServiceAddTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                IReservationRepository reservationRepository = new ReservationRepository(_context);
                IMemberRepository      memberRepository      = new MemberRepository(_context);
                mr = new MemberService(memberRepository);
                Pilot p = await mr.GetPilotById(15);

                cr = new ReservationService(reservationRepository);
                AircraftReservation ar = new AircraftReservation();
                ar.DateFrom   = new DateTime(2019, 08, 29, 14, 23, 00);
                ar.DateTo     = new DateTime(2019, 08, 29, 19, 20, 00);
                ar.TailNumber = "4xCGC";
                ar.IdNumber   = "123456";
                ar.AircraftId = 8;

                ar.ReservationInfo = new UserInfo(p).GetJason();
                var reser = await cr.GetReservation();

                await cr.AddReservation(ar);

                ar.DateFrom = new DateTime(2019, 08, 29, 19, 22, 00);
                ar.DateTo   = new DateTime(2019, 08, 29, 20, 20, 00);
                await cr.AddReservation(ar);

                reser = await cr.GetReservation();

                reser = await cr.GetPilotReservation(ar.IdNumber);

                await cr.DeleteReservation(ar.Id);

                reser = await cr.GetReservation();

                await cr.AddReservation(ar);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 10
0
        public async Task ClubServiceTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                cr       = new ClubRepository(_context);

                ClubService         clubService = new ClubService(cr);
                ICollection <Pilot> clubBaz     = await clubService.GetClubMembers("BAZ");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 11
0
        public async Task RepositoryClubAircrafFlightTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                cr       = new ClubRepository(_context);
                AircraftLogBookRepository acr             = new AircraftLogBookRepository(_context);
                FlightRepository          fr              = new FlightRepository(_context);
                MemberRepository          mr              = new MemberRepository(_context);
                ClubRepository            _clubRepository = new ClubRepository(_context);
                AircraftRepository        ar              = new AircraftRepository(_context);
                ClubService clubService = new ClubService(cr, mr, fr, ar, acr, null);
                int         aircraftId  = 8;
                var         clubSpec    = new ClubWithSpecification("BAZ", false, true);

                var club = (await _clubRepository.ListAsync(clubSpec));
                FlighWithSpecification flightPagingSpec = new FlighWithSpecification(0, 10, 8, 14);
                FlighWithSpecification flightSpec       = new FlighWithSpecification(8, 14);

                var flight = await fr.ListAsync(flightPagingSpec);

                var flightCount = await fr.CountAsync(flightSpec);

                ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId);

                var group = flights.GroupBy(o => o.Pilot);
                foreach (var g in group)
                {
                    System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName);
                    foreach (var gi in g)
                    {
                        System.Diagnostics.Debug.WriteLine(gi.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 12
0
        public async Task ClubServiceAircrafTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                cr       = new ClubRepository(_context);
                ClubService            clubService = new ClubService(cr);
                ICollection <Aircraft> aircraft    = await clubService.GetClubAircraft("BAZ");

                foreach (var ar in aircraft)
                {
                    System.Diagnostics.Debug.WriteLine(ar.ToString());
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }