-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderrepo.cpp
57 lines (48 loc) · 1.28 KB
/
orderrepo.cpp
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
#include "orderrepo.h"
void orderRepo::store(const order &o){
if(existNoOrder(o)){
throw orderRepoException("Comanda exista deja in baza de date");
}
all.push_back(o);
}
bool orderRepo::existNoOrder(const order &o) const{
//verificam daca exista dupa codul comenzii
try {
findByNoOrder(o.getNoOrder());
return true;
} catch (orderRepoException &){
return false;
}
}
const order& orderRepo::findByNoOrder(QString noOrder) const{
for (const auto &o :all){
if(o.getNoOrder() == noOrder){
return o;
}
}
throw orderRepoException("Nu exista comanda in baza de date");
}
const order& orderRepo::findByCompany(QString company) const{
for (const auto &o :all){
if(o.getCompany() == company){
return o;
}
}
throw orderRepoException("Nu exista comanda in baza de date");
}
const order& orderRepo::findByResponsible(QString responsible) const{
for (const auto &o :all){
if(o.getResponsible() == responsible){
return o;
}
}
throw orderRepoException("Nu exista comanda in baza de date");
}
/*
const order& orderRepo::findByMark(QString mark) const{
//todo
}
*/
const QVector<order>& orderRepo::getAllDueDate() const{
return all;
}