-
Notifications
You must be signed in to change notification settings - Fork 0
/
IeBanqueServiceREST.cs
187 lines (149 loc) · 6.45 KB
/
IeBanqueServiceREST.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace eBanque
{
[ServiceContract]
public interface IeBanqueServiceREST
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteId}/Solde",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
CompteDTO GetSolde(string mail, string hashPwd, string compteId);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteId}/Retrait",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void Retrait(string mail, string hashPwd, string compteId, int montant);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteId}/Depot",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void Depot(string mail, string hashPwd, string compteId, int montant);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/OuvrirCompte",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void OuvrirCompte(string mail, string hashPwd, string name);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteId}/CloturerCompte",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void CloturerCompte(string mail, string hashPwd, string compteId);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/addBeneficiaire",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void addBeneficiaire(string mail, string hashPwd, int compteId);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteFromRaw}/Virement",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void Virement(string mail, string hashPwd, string compteFromRaw, int compteTo, int montant);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{compteId}/Historique",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
List<OperationDTO> Historique(string mail, string hashPwd, string compteId);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/SignIn",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void SignIn(string mail, string hashPwd, string nom, string prenom);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/LogIn",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void LogIn(string mail, string hashPwd);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
ClientDTO GetClient(string mail, string hashPwd);
/// /////////////////////
/*
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/GetData",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
List<Client> GetData();*/
}
[DataContract]
public class ClientDTO
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Nom { get; set; }
[DataMember]
public string Prenom { get; set; }
[DataMember]
public string Email { get; set; }
[DataMember]
public List<CompteDTO> Comptes { get; set; }
[DataMember]
public List<CompteLieDTO> Beneficiaires { get; set; }
public ClientDTO(Client client)
{
Id = client.Id;
Nom = client.Nom;
Prenom = client.Prenom;
Email = client.Email;
Comptes = client.Comptes.Select(c => new CompteDTO(c)).ToList();
Beneficiaires = client.Beneficiaires.Select(b => new CompteLieDTO(b)).ToList();
}
}
[DataContract]
public class CompteDTO
{
[DataMember]
public int Id { get; set; }
[DataMember]
public int Solde { get; set; }
[DataMember]
public string Nom { get; set; }
[DataMember]
public List<OperationDTO> Historique { get; set; }
public CompteDTO(Compte compte)
{
Id = compte.Id;
Nom = compte.Nom;
Solde = compte.Solde;
Historique = compte.Historique.Select(o => new OperationDTO(o)).ToList();
}
}
[DataContract]
public class OperationDTO
{
[DataMember]
public int Id { get; set; }
[DataMember]
public DateTime Date { get; set; }
[DataMember]
public int Montant { get; set; }
[DataMember]
public TypeOperation Type { get; set; }
[DataMember]
public string Label { get; set; }
[DataMember]
public CompteLieDTO CompteLie { get; set; }
public OperationDTO(Operation operation)
{
Id = operation.Id;
Date = operation.Date;
Label = operation.Label;
Montant = operation.Montant;
Type = operation.Type;
CompteLie = new CompteLieDTO(operation.CompteLie);
}
}
[DataContract]
public class CompteLieDTO
{
[DataMember]
public string NomProprietaire { get; set; }
[DataMember]
public string PrenomProprietaire { get; set; }
[DataMember]
public string NomCompte { get; set; }
public CompteLieDTO(Compte compte)
{
NomCompte = compte.Nom;
NomProprietaire = compte.Proprietaire.Nom;
PrenomProprietaire = compte.Proprietaire.Prenom;
}
}
}