-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddPerson.hpp
99 lines (85 loc) · 3.16 KB
/
AddPerson.hpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once
#include "Command.hpp"
#include "ValidationData.hpp"
#include "Person.hpp"
#include <memory>
#include <string>
#include <limits> //for numeric_limits
#include <ios> // for std::streamsize
using ansvers = ValidationData::YesNoConfirm;
class AddPerson : public Command {
public:
AddPerson() = default;
AddPerson(std::shared_ptr<ValidationData> validation);
~AddPerson() = default;
void operator()(std::vector<std::shared_ptr<Person>>& person) override;
enum class WhichPerson {
NoPerson = 0,
Student,
Professor,
Back
};
enum class ExistingPersonMenu {
NoChoice,
SaveNew,
LeaveExist,
Edit,
Cancel,
Back
};
enum class EditPerson {
NoChoice,
LeaveOld,
AddNew,
Edit,
Cancel
};
private:
WhichPerson selectPerson() ;
std::string insertPersonName();
std::string insertPersonSurname();
std::string insertPersonAddress();
std::string insertPersonPesel();
std::string insertPersonGender();
std::string insertStudentIndexNumber();
std::string insertProfessorSalary();
void generateData();
void addingPerson(std::vector<std::shared_ptr<Person>>& person);
void addStudentToDatabase(std::vector<std::shared_ptr<Person>>& person);
void addProfessorToDatabase(std::vector<std::shared_ptr<Person>>& person);
void confirmAddRecord(std::vector<std::shared_ptr<Person>>& person);
std::vector<std::shared_ptr<Person>>::iterator isPersonExist(std::vector<std::shared_ptr<Person>>& person);
void printAddingPerson();
void printExistingPerson(std::shared_ptr<Person>& person);
void existingPerson(std::vector<std::shared_ptr<Person>>& person);
void printMenuIfPersonExist(std::vector<std::shared_ptr<Person>>& person);
ExistingPersonMenu isPersonExistMenu(AddPerson::ExistingPersonMenu userChoice, std::vector<std::shared_ptr<Person>>& person);
ExistingPersonMenu isPersonExistMenuUserChoice(int optionNumber);
ExistingPersonMenu saveNewIsPersonExist(std::vector<std::shared_ptr<Person>>& person);
ExistingPersonMenu leaveExistIsPersonExist();
ExistingPersonMenu editIsPersonExist();
ExistingPersonMenu cancelIsPersonExist();
void editName();
void editSurname();
void editAddress();
void editPeselNumber();
void editGender();
void editIndexNumber();
void editSalary();
void clearTemporaryData();
std::string confirmEditPerson(std::string oldRecord, std::string newRecord, EditPerson userAnswer, std::string editAnswer = "");
int printMenuConfirmEditPerson();
EditPerson userChoiceConfirmEditPerson();
std::shared_ptr<ValidationData>validation_;
WhichPerson whichPerson_ { WhichPerson::NoPerson };
std::vector<std::shared_ptr<Person>>::iterator existPerson_ { nullptr };
std::string name_ { };
std::string surname_ { };
std::string address_ { };
std::string peselNumber_ { };
std::string gender_ { };
std::string indexNumber_ { };
std::string salary_ { };
ansvers yesNoAnsver_ { ansvers::NoConfirm };
ExistingPersonMenu existingPersonMenu_ { ExistingPersonMenu::NoChoice };
};