-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount_service.h
More file actions
33 lines (26 loc) · 1014 Bytes
/
account_service.h
File metadata and controls
33 lines (26 loc) · 1014 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
30
31
32
33
#pragma once
#include "model.h"
#include "storage.h"
#include "crypto.h"
#include <optional>
class AccountService {
public:
explicit AccountService(Storage& storage);
Account create_account(const std::string& name,
const std::string& father_name,
const std::string& national_id,
const std::string& phone,
const std::string& email,
const std::string& password,
double initial_deposit);
std::optional<Account> authenticate(const std::string& account_id, const std::string& password);
std::optional<Account> get_account(const std::string& account_id);
bool deposit(const std::string& account_id, double amount);
bool withdraw(const std::string& account_id, double amount);
bool update_contact(const std::string& account_id, const std::string& phone, const std::string& email);
private:
Storage& storage_;
std::vector<Account> accounts_;
void persist();
Account* find_account_mutable(const std::string& account_id);
};