public IHttpActionResult GetAllFlights() { if (anonymousUser.GetAllFlights() == null) { return(NotFound()); } return(Ok(anonymousUser.GetAllFlights())); }
public void GenerateTickets(int ticketsPerCustomer) { //checking every scenario: /* * no problems at all - V * has tickets to all flights already - V * all flights are full - V * half-way through has tickets to all flights already - stopped thinking, but i think it's all good * half-way through all flights are full - */ Random rng = new Random(); IList <Flight> flights = anonymousFacade.GetAllFlights(); IList <Customer> customers = dbGeneratorFacade.GetAllCustomers(); int noTicketsTries = 1000; //because every single customer might try to get a ticket to a full flight foreach (var customer in customers) { if (noTicketsTries <= 0) { break; } int personalTries = 1000; for (int i = 0; i < ticketsPerCustomer; i++) { if (noTicketsTries <= 0) { break; } if (personalTries <= 0) { break; } try { Flight randomFlight = flights[rng.Next(0, flights.Count - 1)]; dbGeneratorFacade.CreateTicket(customer, randomFlight); //what if no tickets available? (there's a tries system now) //what if i have tickets to all flights? (there are personal tries now) } catch (TicketAlreadyExistsException ex) { i--; personalTries--; } catch (NoMoreTicketsException ex) { i--; noTicketsTries--; } } } }
public IHttpActionResult GetAllFlights() { IList <Flight> flights = facade.GetAllFlights(); if (flights.Count > 0) { return(Ok(flights)); } return(NotFound()); }
public void GetAllFlights() { Flight expectedFlight = new Flight(1, 1, 1, new DateTime(2000, 01, 01), new DateTime(2000, 01, 01), 1); expectedFlight.Id = 1; List <Flight> list_of_flights = (List <Flight>)anonymousUserFacade.GetAllFlights(); List <Flight> expected_list_of_flights = new List <Flight> { expectedFlight }; CollectionAssert.AreEqual(list_of_flights, expected_list_of_flights); }
public IActionResult GetAllFlights() { IActionResult result = SafeExecute(() => { IList <Flight> flights = AnonymousUserFacade.GetAllFlights(); if (flights.Count < 1) { return(NoContent()); } return(Ok(flights)); }); return(result); }
public void GetAllFlights_Test() { AnonymousUserFacade anonymous = new AnonymousUserFacade(); var list = anonymous.GetAllFlights(); Assert.IsTrue(list.Count > 0); }
public void AnonymouseFacade_GetAllFlights_FlightsFound() { AnonymousUserFacade facade = FlyingCenterSystem.GetInstance().GetAnonymousFacade(); IList <Flight> flights = facade.GetAllFlights(); Assert.AreNotEqual(null, flights); for (int i = 0; i < flights.Count; i++) { Assert.AreEqual(TestResource.FlightsId[i], flights[i].Id); Assert.AreEqual(TestResource.DepartureTimes[i], flights[i].DepartureTime); Assert.AreEqual(TestResource.LandingTimes[i], flights[i].LandingTime); Assert.AreEqual(TestResource.AirlineCompaniesId[i], flights[i].AirlineCompanyId); Assert.AreEqual(TestResource.OriginCountryCodes[i], flights[i].OriginCountryCode); Assert.AreEqual(TestResource.DestinationCountryCodes[i], flights[i].DestinationCountryCode); Assert.AreEqual(TestResource.Vacancies[i], flights[i].RemainingTickets); } }
public void GetAllFlights() { UserRepository testUr = new UserRepository("dad", "aes", RolesEnum.admin); Admin testAdmin = new Admin("dav,", "id", 3); FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token, out FacadeBase facade); LoginToken <Admin> myToken = token as LoginToken <Admin>; LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade; myFacade.CreateNewAdmin(myToken, testUr, testAdmin); Country country = new Country("Israel"); myFacade.CreateNewCountry(myToken, country); AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID); UserRepository airlineTestUr = new UserRepository("rad", "ass", RolesEnum.airline); myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country); Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID); FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir, out FacadeBase facadeAir); LoginToken <AirlineCompany> myTokenair = tokenAir as LoginToken <AirlineCompany>; LoggedInAirlineFacade myFacadeAir = facadeAir as LoggedInAirlineFacade; myFacadeAir.CreateFlight(myTokenair, flight); AnonymousUserFacade anonymousUserFacade = new AnonymousUserFacade(); List <Flight> flights = (List <Flight>)anonymousUserFacade.GetAllFlights(); Assert.IsNotNull(flights); }
public void AnonymouseFacade_GetAllFlights_FlightsReceived() { Flight newFlight = null; InitDBUnitTest.InitDB(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); AnonymousUserFacade anonymousFacade = GetAnonymousFacade(); IList <Flight> flights1 = anonymousFacade.GetAllFlights(); newFlight = CreateNewFlight1(); newFlight.ID = flight.ID; newFlight.AIRLINECOMPANY_ID = flight.AIRLINECOMPANY_ID; newFlight.ORIGIN_COUNTRY_CODE = flight.ORIGIN_COUNTRY_CODE; newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE; IList <Flight> flights2 = new List <Flight>(); flights2.Add(newFlight); List <Flight> f1 = (List <Flight>)flights1; List <Flight> f2 = (List <Flight>)flights2; CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public IHttpActionResult GetFlightsByFewParameters([FromUri] int fromcountry = 0, [FromUri] int tocountry = 0, [FromUri] string fromdate = DEFAULT_DATE, [FromUri] string todate = DEFAULT_DATE, [FromUri] double flightduration = 0d) { IHttpActionResult result = ExecuteSafe(() => { //DateTime fromDate = DateTime.Parse(fromdate); //DateTime toDate = DateTime.Parse(todate); List <Flight> allFoundFlights = (List <Flight>)facade.GetAllFlights(); allFoundFlights = RemoveUnmatchedFlights(allFoundFlights, fromcountry, tocountry, DateTime.Parse(fromdate), DateTime.Parse(todate), flightduration); if (allFoundFlights.Count < 1) { return(Content(HttpStatusCode.NoContent, "No Flight Found Matching Sent Parameters.")); } return(Content(HttpStatusCode.OK, allFoundFlights)); }); return(result); // for debug - break point here }
public void CRUDAirlineCompanyAndAnonymousFacadeTests() { ResetWhatIsNeeded(); LoginService ls = new LoginService(); LoginToken <AirlineCompany> loginToken = new LoginToken <AirlineCompany>(); ls.TryAirlineLogin("company", "company", out loginToken); LoggedInAirlineFacade loggedInAirlineFacade = new LoggedInAirlineFacade(); AnonymousUserFacade anonymousUserFacade = new AnonymousUserFacade(); //create flight test DateTime departureTime = DateTime.Now.AddDays(1); DateTime landingTime = departureTime.AddDays(1).AddHours(1); Flight f = new Flight(-1, loginToken.User.ID, 1, 3, departureTime, landingTime, 10, 10); loggedInAirlineFacade.CreateFlight(loginToken, f); IList <Flight> flights = anonymousUserFacade.GetAllFlights(); //anonymous - get all flights test Assert.IsTrue(flights.Count == 1); f = flights[0]; //anonymous - get flights vacancies Dictionary <Flight, int> dict = anonymousUserFacade.GetAllFlightsVacancy(); int remainingTickets; Assert.IsTrue(dict.TryGetValue(f, out remainingTickets)); Assert.AreEqual(10, remainingTickets); //anonymous - get flight by ID Assert.AreEqual(f, anonymousUserFacade.GetFlightById(f.ID)); //anonymous - get flight by departure date Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByDepatrureDate(f.DepartureTime))); //anonymous - get flight by landing date Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByLandingDate(f.LandingTime))); //anonymous - get flight by destination country Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByDestinationCountry(f.DestinationCountryID))); //anonymous - get flight by origin country Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByOriginCountry(f.OriginCountryID))); //update flight Flight newFlight = new Flight(f.ID, f.AirlineCompanyID, f.OriginCountryID, f.DestinationCountryID, f.DepartureTime.AddMinutes(30), f.LandingTime.AddMinutes(30), f.RemainingTickets, f.MaxTickets); loggedInAirlineFacade.UpdateFlight(loginToken, newFlight); f = anonymousUserFacade.GetFlightById(newFlight.ID); Assert.IsTrue(f.DepartureTime.Equals(newFlight.DepartureTime) & f.DepartureTime.Equals(newFlight.DepartureTime)); //cancel flight - test only the cancelling part, not the removing ticket part as there are //no tickets at this point loggedInAirlineFacade.CancelFlight(loginToken, newFlight); Assert.IsTrue(anonymousUserFacade.GetFlightById(newFlight.ID) == null); }
public IHttpActionResult GetAllFlights() { List <Flight> allFlights = _anonymous.GetAllFlights().ToList(); if (allFlights.Count == 0) { return(NotFound()); } return(Ok(allFlights)); }
public IHttpActionResult GetAllFlights() { IList <Flight> flights = anonymous.GetAllFlights(); if (flights.Count == 0) { return(NotFound()); } return(Ok(flights)); }
public void GetAllFlights() { List <Flights> flights = (List <Flights>)anonymousUser.GetAllFlights(); List <Flights> expected = new List <Flights>() { new Flights(1, 1, 3, 6, new DateTime(2021, 03, 26), new DateTime(2021, 04, 26), 10), new Flights(2, 2, 5, 2, new DateTime(2021, 01, 17), new DateTime(2021, 04, 17), 23) }; CollectionAssert.AreEqual(expected, flights); }
public void GetAllFlights_ReturnsListOfAllFlights() { AnonymousUserFacade userFacade = (AnonymousUserFacade)FlyingCenterSystem.FacadeList[0]; List <Flight> flights = (List <Flight>)userFacade.GetAllFlights(); Assert.AreEqual(5, flights.Count); foreach (Flight flight in flights) { Assert.IsNotNull(flight); } }
public IHttpActionResult GetAllFlights() { AnonymousUserFacade anonymousFacade = (AnonymousUserFacade)f.GetFacade(null); IList <Flight> flights = anonymousFacade.GetAllFlights(); if (flights == null || flights.Count == 0) { return(NotFound()); } return(Ok(flights)); }
public IList <Flight> GetAllFlights() { try { IList <Flight> flights = facade.GetAllFlights(); return(flights); } catch (Exception ex) { throw ex; } }
public IHttpActionResult GetAllFlights() { List <Flight> AllFlights = AnonymousFacade.GetAllFlights().ToList(); if (AllFlights.Count == 0) { return(NotFound()); } else { return(Ok(AllFlights)); } }
public void GetAllFlightsTest() { AnonymousUserFacade facade = FlightsCenterSystem.GetInstance().GetFacade <Anonymous>(null) as AnonymousUserFacade; TestData.DeleteAllData(); flightDAOPGSQL.Add(CreateFlightForTest()); var f_list = facade.GetAllFlights(); Assert.AreNotEqual(f_list, null); Assert.AreEqual(f_list.Count, 1); }
public IHttpActionResult GetAllFlights() { IHttpActionResult result = controllersCenter.ExecuteSafe(() => { IList <Flight> flights = facade.GetAllFlights(); if (flights.Count < 1) { return(Content(HttpStatusCode.NoContent, "Sorry, But Currently, Has No Flights... Please Try Later.")); } return(Content(HttpStatusCode.OK, flights)); }); return(result); // for debug - break point here }
public IHttpActionResult GetAllFlights() { AnonymousUserFacade facade = new AnonymousUserFacade(); IList <Flight> flights = facade.GetAllFlights(); if (flights.Count == 0) { return(StatusCode(HttpStatusCode.NoContent)); } else { return(Ok(flights)); } }
public IHttpActionResult GetAllFlights() { AllFlights = F.GetAllFlights().ToList(); if (AllFlights.Count == 0) { return(NotFound()); } return(Ok(AllFlights)); }
public MainWindow() { BuyTicketCommand = new DelegateCommand(BuyTicket, IsBuyTicketCommandEnabled); InitializeComponent(); flights = anonymousUserFacade.GetAllFlights(); listBoxFlights.ItemsSource = flights; this.DataContext = this; Task.Run(() => { while (true) { BuyTicketCommand.RaiseCanExecuteChanged(); Thread.Sleep(500); } }); }
public async Task <ActionResult <Flights> > GetAllFlights() { IList <Flights> result = null; try { result = await Task.Run(() => facade.GetAllFlights()); } catch (Exception ex) { return(StatusCode(400, $"{{ error: \"{ex.Message}\" }}")); } if (result == null) { return(StatusCode(204, "{ }")); } return(Ok(result)); }
public async Task <ActionResult <Flight> > GetAllFlights() { AnonymousUserFacade facade = new AnonymousUserFacade(false); IList <Flight> result = null; try { result = await Task.Run(() => facade.GetAllFlights()); } catch (Exception ex) { return(StatusCode(400, $"{{ error: can't get all flights \"{ex.Message}\" }}")); } if (result == null) { return(StatusCode(204, "{The list of flight is empty. Nothing to return. }")); } return(Ok(result)); }
public void AnonymouseFacade_GetAllFlightsVacancy_FlightsVacancyFound() { AnonymousUserFacade facade = FlyingCenterSystem.GetInstance().GetAnonymousFacade(); Dictionary <Flight, int> flightsVacancy = facade.GetAllFlightsVacancy(); Assert.AreNotEqual(flightsVacancy, null); IList <Flight> flights = facade.GetAllFlights(); int i = 0; foreach (Flight flight in flights) { flightsVacancy.TryGetValue(flight, out int vacancy); Assert.AreEqual(TestResource.Vacancies[i], vacancy); i = i + 1; } }
public IHttpActionResult GetAllFlights() { return(Json(_facade.GetAllFlights())); }
public IHttpActionResult GetAllFlights() { IList <Flight> flights = facade.GetAllFlights(); return(Ok(flights)); }
public async Task <ActionResult <List <Flight> > > GetAllFlights() { var result = await Task.Run(() => facade.GetAllFlights()); return(StatusCode(200, result)); }
public Flight GetFlightFotTest() { Flight f = AnonymousFacade.GetAllFlights().ToList()[0]; return(f); }