private string GetMainPageRaw() { try { return(WebScrp.GetPageTextRaw(WebScrpSwiss.URL)); } catch (Exception ex) { throw new System.Exception("Swiss page probably does not responding. Error: " + ex.Message); } }
public override void TryToAddVehicles(int vehiclesToAdd, int vehicleLimit) { string mainPageRaw; try { mainPageRaw = WebScrp.GetPageTextRaw(WebScrpAxa.URL); } catch (Exception ex) { string excDetails = ex.Message; // axa page probably does not responding return; } List <Vehicle> vehiclesFromDb = Repo.FindAllActive(); int vehicleActiveTotal = vehiclesFromDb.Count(); for (int i = 0; i < vehiclesToAdd; i++) { if (vehicleActiveTotal >= vehicleLimit) { return; } try { Vehicle vehicleUnique = WebScrpAxa.GetUniqueVehicleFromMain(mainPageRaw, vehiclesFromDb); Repo.Create(vehicleUnique); vehiclesFromDb.Add(vehicleUnique); vehicleActiveTotal++; } catch (Exception ex) { string excDetails = ex.Message; //no new car will be created } } }