-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (27 loc) · 688 Bytes
/
Copy pathmain.cpp
File metadata and controls
29 lines (27 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "pqxx/pqxx"
#include "nlohmann/json.hpp"
#include "weather_data_collector.h"
#include "weather_analysis.h"
#include "postgres_db_manager.h"
#include "UI.h"
#include "city_builder.h"
#include "iostream"
int main() {
auto db_manager = std::make_shared<PostgresDBManager>();
UI ui(db_manager);
std::string city_name = ui.AskAndGetCity();
const auto city = db_manager->GetCity(city_name);
if (city) {
ui.PrintCity(city.value());
} else {
try {
CityBuilder builder;
auto city = builder.Build(city_name, ui.AskAndGetCountry());
db_manager->InsertCity(*city);
ui.PrintCity(*city);
} catch (...) {
return 0;
}
}
return 0;
}