/
PrintSystem.svc.cs
217 lines (144 loc) · 5.54 KB
/
PrintSystem.svc.cs
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using WebBLL;
using WebDAL;
using WebDTO;
namespace WebProject
{
// REMARQUE : vous pouvez utiliser la commande Renommer du menu Refactoriser pour changer le nom de classe "PrintSystem" à la fois dans le code, le fichier svc et le fichier de configuration.
// REMARQUE : pour lancer le client test WCF afin de tester ce service, sélectionnez PrintSystem.svc ou PrintSystem.svc.cs dans l'Explorateur de solutions et démarrez le débogage.
public class PrintSystem : IPrintSystem
{
public Student GetDataUsingDataContract(Student student)
{
throw new NotImplementedException();
}
public Student GetStudentById(int Id)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
Student student = studentManager.GetStudentById(Id);
return student;
}
public int GetIdStudent(string login)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
int IdStudent = studentManager.GetIdStudent(login);
return IdStudent;
}
public string GetPassword(int id, string login)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
string password = studentManager.GetPassword(id, login);
return password;
}
public Student GetStudentByUserName(string UserName)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
Student student = studentManager.GetStudentByUserName(UserName);
return student;
}
public Student AuthenficationUser(string UserName)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
Student student = studentManager.GetStudentByUserName(UserName);
return student;
}
public int Authentification(string UserName, string Pass)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
int IdStudent = studentManager.GetIdStudent(UserName);
string Password = studentManager.GetPassword(IdStudent, Pass);
if (Pass == Password)
{
return IdStudent;
}
else
{
return 0;
}
}
public void AuthentificationNotification (int number)
{
if (number > 0)
{
Console.WriteLine("Authentification successfull") ;
}
else
{
Console.WriteLine("Authentification denied");
}
}
public double AddAmount(Student student, string UserName, double money)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
return studentManager.AddAmount(student, UserName, money);
}
public int ConvertCredit(Student student, string UserName, string Pass)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
double credit = 0;
int pages = 0;
int userId = 0;
userId = Authentification(UserName,Pass);
if (userId > 0)
{
credit = student.Credit;
pages = Convert.ToInt32(credit / 0.08);
}
else
{
return 0;
}
return pages;
}
public int UpdateTransaction(Student student, double mouve)
{
IStudentDB studentDB = new StudentDB();
IStudentManager studentManager = new StudentManager(studentDB);
ITransactionDB transactionDB = new TransactionDB();
ITransactionManager transactionManager = new TransactionManager(transactionDB);
return transactionManager.UpdateTransaction(student, mouve);
}
public List<Test> GetTransactionById(int id)
{
ITransactionDB transactionDB = new TransactionDB();
ITransactionManager transactionManager = new TransactionManager(transactionDB);
return transactionManager.GetTransactionById(id);
}
/*
public void PrintTransactionList(Test[] test)
{
Console.WriteLine("Salut ");
int count = 0;
foreach (Test testPrint in test)
{
Test i = testPrint;
double argent = i.Mouvement;
count++;
Console.WriteLine($"Transaction nr. #{count}: {argent}");
}
}
*/
/*
public double GetMovement(Test transa)
{
ITransactionDB transactionDB = new TransactionDB();
ITransactionManager transactionManager = new TransactionManager(transactionDB);
double mouvement = transactionManager.GetTransactionById(transa.IdTransaction).Mouvement;
return mouvement;
}
*/
}
}