public ListOfQuotesViewModels MapListOfQuotesToListOfQuotesViewModel(ListOfQuotes listOfQuotes) { Currency currency = listOfQuotes.Currencies.FirstOrDefault(); CurrencyViewModel currencyViewModel = new CurrencyViewModel(); if (!(currency is null)) { currencyViewModel.Code = currency.Code; currencyViewModel.Symbol = currency.Symbol; currencyViewModel.ThousandsSeparator = currency.ThousandsSeparator; currencyViewModel.DecimalSeparator = currency.DecimalSeparator; currencyViewModel.DecimalDigits = currency.DecimalDigits; } var quoteViewModels = new List <QuoteViewModel>(); foreach (var quote in listOfQuotes.Quotes) { var outboundLeg = new OutboundLegViewModel() { OriginPlaceName = listOfQuotes.Places.FirstOrDefault(x => x.PlaceId == quote.OutboundLeg.OriginId).Name, DestinationPlaceName = listOfQuotes.Places.FirstOrDefault(x => x.PlaceId == quote.OutboundLeg.DestinationId).Name, DepartureDate = quote.OutboundLeg.DepartureDate, CarrierNames = quote.OutboundLeg.CarrierIds.Select(x => listOfQuotes.Carriers.FirstOrDefault(y => y.CarrierId == x).Name).ToList() }; var InboundLeg = new InboundLegViewModel() { OriginPlaceName = listOfQuotes.Places.FirstOrDefault(x => x.PlaceId == quote.InboundLeg.OriginId).Name, DestinationPlaceName = listOfQuotes.Places.FirstOrDefault(x => x.PlaceId == quote.InboundLeg.DestinationId).Name, DepartureDate = quote.InboundLeg.DepartureDate, CarrierNames = quote.InboundLeg.CarrierIds.Select(x => listOfQuotes.Carriers.FirstOrDefault(y => y.CarrierId == x).Name).ToList() }; var quoteViewModel = new QuoteViewModel() { QuoteId = quote.QuoteId, MinPrice = quote.MinPrice, Direct = quote.Direct, InboundLeg = InboundLeg, OutboundLeg = outboundLeg }; quoteViewModels.Add(quoteViewModel); } return(new ListOfQuotesViewModels() { Currency = currencyViewModel, Quotes = quoteViewModels }); }
public virtual async Task <ListOfQuotes> GetBrowseQuotes( string originPlace, string destinationPlace, string country = "UK", string currency = "GBP", string locale = "en-GB", string outboundPartialDate = "anytime", string inboundPartialDate = "") { ListOfQuotes result = await HttpHelper.Get <ListOfQuotes>($"{_apiEndpoint}browsequotes/v1.0/{country}/{currency}/{locale}/{originPlace}/{destinationPlace}/{outboundPartialDate}/{inboundPartialDate}?apiKey={_apiKey}"); return(result); }
public async Task <ListOfQuotesViewModels> GetBrowseQuotes( string originPlace, string destinationPlace, string country = "UK", string currency = "GBP", string locale = "en-GB", string outboundPartialDate = "anytime", string inboundPartialDate = "") { ListOfQuotes result = await _skyscannerProvider.GetBrowseQuotes(originPlace, destinationPlace, country, currency, locale, outboundPartialDate, inboundPartialDate); ListOfQuotesViewModels listOfQuoteViewModels = _skycannerMapper.MapListOfQuotesToListOfQuotesViewModel(result); return(listOfQuoteViewModels); }
static void Main(string[] args) { try { ListOfQuotes quoateGenerator = new ListOfQuotes(); RandomQuoteCLI startUp = new RandomQuoteCLI(quoateGenerator); startUp.MainMenu(); } catch (Exception ex) { Console.WriteLine("The following issue occured while running the random quote generator: "); Console.WriteLine(ex.Message); Console.WriteLine("The program will now close..."); Console.ReadKey(); } }
public RandomQuoteCLI(ListOfQuotes quoteCLI) { _listOfQuoteCLI = quoteCLI; }
public void ManageFolders() { for (int i = 1; i <= 10; i++) { //moves old day folders if (Directory.Exists(GetDayPath(DateTime.Now.AddDays(-i)))) { if (Directory.Exists(GetMonthPath(DateTime.Now.AddDays(-i)) + "\\" + GetDayName(DateTime.Now.AddDays(-i)))) { throw new Exception("\n\nDay " + GetDayName(DateTime.Now.AddDays(-i)) + " exists both in \n" + InitialPath + "\n and in \n" + GetMonthPath(DateTime.Now.AddDays(-i)) + " . Please review manually.\n\n"); } Directory.Move(GetDayPath(DateTime.Now.AddDays(-i)), GetMonthPath(DateTime.Now.AddDays(-i)) + "\\" + GetDayName(DateTime.Now.AddDays(-i))); ManageChanges++; Console.WriteLine("[Folder Moved] \n " + GetDayPath(DateTime.Now.AddDays(-i)) + " -> " + GetMonthPath(DateTime.Now.AddDays(-i)) + "\\" + GetDayName(DateTime.Now.AddDays(-i))); } } Thread.Sleep(500); for (int i = 1; i <= 10; i++) { //moves old month folders if (Directory.Exists(GetMonthPath(DateTime.Now.AddMonths(-i)))) { if (Directory.Exists(GetYearPath(DateTime.Now.AddMonths(-i)) + "\\" + GetMonthName(DateTime.Now.AddMonths(-i)))) { throw new Exception("\n\nMonth " + GetMonthName(DateTime.Now.AddMonths(-i)) + " exists both in \n" + InitialPath + "\n and in \n" + GetYearPath(DateTime.Now.AddMonths(-i)) + " . Please review manually.\n\n"); } Directory.Move(GetMonthPath(DateTime.Now.AddMonths(-i)), GetYearPath(DateTime.Now.AddMonths(-i)) + "\\" + GetMonthName(DateTime.Now.AddMonths(-i))); ManageChanges++; Console.WriteLine("[Folder Moved] \n " + GetMonthPath(DateTime.Now.AddMonths(-i)) + " -> " + GetYearPath(DateTime.Now.AddMonths(-i)) + "\\" + GetMonthName(DateTime.Now.AddMonths(-i))); } } //create current year if (!Directory.Exists(GetYearPath(DateTime.Now))) { Directory.CreateDirectory(GetYearPath(DateTime.Now)); ManageChanges++; Console.WriteLine("[Folder Created] \n " + GetYearPath(DateTime.Now)); } //create current month if (!Directory.Exists(GetMonthPath(DateTime.Now))) { if (Directory.Exists(GetYearPath(DateTime.Now) + "\\" + GetMonthName(DateTime.Now))) { Directory.Move(GetYearPath(DateTime.Now) + "\\" + GetMonthName(DateTime.Now), GetMonthPath(DateTime.Now)); ManageChanges++; Console.WriteLine("[Folder Moved] \n " + GetYearPath(DateTime.Now) + "\\" + GetMonthName(DateTime.Now) + " -> " + GetMonthPath(DateTime.Now)); } else { Directory.CreateDirectory(GetMonthPath(DateTime.Now)); ManageChanges++; Console.WriteLine("[Folder Created] \n " + GetMonthPath(DateTime.Now)); } } //create current day if (!Directory.Exists(GetDayPath(DateTime.Now))) { if (Directory.Exists(GetMonthPath(DateTime.Now) + "\\" + GetDayName(DateTime.Now))) { Directory.Move(GetMonthPath(DateTime.Now) + "\\" + GetDayName(DateTime.Now), GetDayPath(DateTime.Now)); ManageChanges++; Console.WriteLine("[Folder Moved] \n " + GetMonthPath(DateTime.Now) + "\\" + GetDayName(DateTime.Now) + " -> " + GetDayPath(DateTime.Now)); } else { Directory.CreateDirectory(GetDayPath(DateTime.Now)); ManageChanges++; Console.WriteLine("[Folder Created] \n " + GetDayPath(DateTime.Now)); Random r = new Random(); int index = r.Next(0, ListOfQuotes.Count() - 1); File.WriteAllText(Path.Combine(GetDayPath(DateTime.Now), "DW.txt"), ListOfQuotes[index]); } } }