|
@@ -8,6 +8,8 @@ using System.Text;
|
8
|
8
|
using UnivateProperties_API.Context;
|
9
|
9
|
using UnivateProperties_API.Helpers;
|
10
|
10
|
using UnivateProperties_API.Model.Communication;
|
|
11
|
+using UnivateProperties_API.Model.ProcessFlow;
|
|
12
|
+using UnivateProperties_API.Model.Timeshare;
|
11
|
13
|
using UnivateProperties_API.Model.Users;
|
12
|
14
|
|
13
|
15
|
namespace UnivateProperties_API.Repository.Communication
|
|
@@ -38,23 +40,14 @@ namespace UnivateProperties_API.Repository.Communication
|
38
|
40
|
|
39
|
41
|
public void ContactUs(MailModel mm)
|
40
|
42
|
{
|
41
|
|
- string property = mm.Property;
|
42
|
|
- string phone = mm.Phone;
|
43
|
|
- string name = mm.Name;
|
44
|
|
- string email = mm.Email;
|
45
|
|
- string message = mm.Message;
|
46
|
|
- var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "ContactUs").ToList();
|
47
|
|
- string body = "<div style=\"margin: 5px\">" +
|
48
|
|
- "<h4>Contact from: " + name + "!</h4>" +
|
49
|
|
- "<h4>Email: " + email + "</h4>" +
|
50
|
|
- "<h4>Phone: " + phone + "</h4>" +
|
51
|
|
- "<h4>Property: " + property + "</h4>" +
|
52
|
|
- "<div>" +
|
53
|
|
- "<h4>Message: </h4>" +
|
54
|
|
- "<p>" + message + "</p>" +
|
55
|
|
- "</div>" +
|
56
|
|
- "</div>" +
|
57
|
|
- "</div>";
|
|
43
|
+ var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "ContactUs").ToList();
|
|
44
|
+ string body = _dbContext.Templates.Where(x => x.Name == "ContactUs").FirstOrDefault().Body;
|
|
45
|
+
|
|
46
|
+ body = body.Replace("[FULLNAME]", mm.Name);
|
|
47
|
+ body = body.Replace("[USEREMAIL]", mm.Email);
|
|
48
|
+ body = body.Replace("[USERCELLPHONE]", mm.Phone);
|
|
49
|
+ body = body.Replace("[PROPERTYREF]", mm.Property);
|
|
50
|
+ body = body.Replace("[USERMESSAGE]", mm.Message);
|
58
|
51
|
|
59
|
52
|
string toList = "";
|
60
|
53
|
int emailCount = 0;
|
|
@@ -93,26 +86,19 @@ namespace UnivateProperties_API.Repository.Communication
|
93
|
86
|
}
|
94
|
87
|
|
95
|
88
|
public void EnquireNow(MailModel mm)
|
96
|
|
- {
|
97
|
|
- string phone = mm.Phone;
|
98
|
|
- string name = mm.Name;
|
99
|
|
- string email = mm.Email;
|
100
|
|
- string message = mm.Message;
|
101
|
|
- var prop = _dbContext.Properties.Where(p => p.Id == int.Parse(mm.Property)).FirstOrDefault();
|
102
|
|
- var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "EnquireNow").ToList();
|
103
|
|
- string body = "<div style=\"margin: 5px\">" +
|
104
|
|
- "<h4>Contact from: " + name + "!</h4>" +
|
105
|
|
- "<h4>Email: " + email + "</h4>" +
|
106
|
|
- "<h4>Phone: " + phone + "</h4>" +
|
107
|
|
- "<div>" +
|
108
|
|
- "<h4>Property: </h4>" +
|
109
|
|
- "<p>" + prop.Id + "</p>" +
|
110
|
|
- "<p>" + prop.PropertyName + "</p>" +
|
111
|
|
- "<p>" + prop.PropertyRef + "</p>" +
|
112
|
|
- "<p>" + prop.Price + "</p>" +
|
113
|
|
- "</div>" +
|
114
|
|
- "</div>" +
|
115
|
|
- "</div>";
|
|
89
|
+ {
|
|
90
|
+ var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "EnquireNow").Where(y => y.IsDeleted == false).ToList();
|
|
91
|
+ string body = _dbContext.Templates.Where(x => x.Name == "EnquireNow").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
|
|
92
|
+ var property = _dbContext.Properties.Where(x => x.Id == Convert.ToInt32(mm.Property)).FirstOrDefault();
|
|
93
|
+
|
|
94
|
+ body = body.Replace("[FULLNAME]", mm.Name);
|
|
95
|
+ body = body.Replace("[USEREMAIL]", mm.Email);
|
|
96
|
+ body = body.Replace("[USERCELLPHONE]", mm.Phone);
|
|
97
|
+ body = body.Replace("[PROPERTYID]", mm.Property);
|
|
98
|
+ body = body.Replace("[PROPERTYNAME]", property.PropertyName);
|
|
99
|
+ body = body.Replace("[PROPERTYREF]", property.PropertyRef);
|
|
100
|
+ body = body.Replace("[PROPERTYPRICE]", property.Price.ToString());
|
|
101
|
+ body = body.Replace("[USERMESSAGE]", mm.Message);
|
116
|
102
|
|
117
|
103
|
string toList = "";
|
118
|
104
|
int emailCount = 0;
|
|
@@ -141,7 +127,7 @@ namespace UnivateProperties_API.Repository.Communication
|
141
|
127
|
mail.BodyEncoding = Encoding.ASCII;
|
142
|
128
|
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
|
143
|
129
|
mail.Sender = new MailAddress(host.User, "UniVate Properties");
|
144
|
|
- mail.From = new MailAddress(mm.ToAddress, "Admin");
|
|
130
|
+ mail.From = new MailAddress(mm.Email, mm.Name);
|
145
|
131
|
|
146
|
132
|
smtp.UseDefaultCredentials = host.NeedsAuthorize;
|
147
|
133
|
smtp.Credentials = host.GetNetworkCredential();
|
|
@@ -185,6 +171,194 @@ namespace UnivateProperties_API.Repository.Communication
|
185
|
171
|
}
|
186
|
172
|
}
|
187
|
173
|
|
|
174
|
+ public void WeekOfferMadeOwner(TimeshareWeek week, BidItem bid)
|
|
175
|
+ {
|
|
176
|
+ var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekOfferMade-Owner").Where(y => y.IsDeleted == false).ToList();
|
|
177
|
+ string body = _dbContext.Templates.Where(x => x.Name == "WeekOfferMade-Owner").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
|
|
178
|
+
|
|
179
|
+ body = body.Replace("[OWNER]", week.DisplayOwner);
|
|
180
|
+ body = body.Replace("[RESORTNAME]", week.ResortName);
|
|
181
|
+ body = body.Replace("[UNITNUMBER]", week.UnitNumber);
|
|
182
|
+ body = body.Replace("[MODULE]", week.Module);
|
|
183
|
+ body = body.Replace("[OFFERMADE]", bid.Amount.ToString());
|
|
184
|
+ body = body.Replace("[FULLNAME]", bid.BidMaker.Display);
|
|
185
|
+ body = body.Replace("[USEREMAIL]", bid.BidMaker.Email);
|
|
186
|
+ body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
|
|
187
|
+ body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
|
|
188
|
+ body = body.Replace("[USERCOMMENT]", bid.Comment);
|
|
189
|
+
|
|
190
|
+ string toList = "";
|
|
191
|
+ int emailCount = 0;
|
|
192
|
+ foreach (var recipient in recipients)
|
|
193
|
+ {
|
|
194
|
+ toList += recipient.RecipientMail + ";, ";
|
|
195
|
+ emailCount++;
|
|
196
|
+ }
|
|
197
|
+
|
|
198
|
+ if (toList.Length > 0)
|
|
199
|
+ {
|
|
200
|
+ if (emailCount == 1)
|
|
201
|
+ toList = toList.Substring(0, toList.Length - 3);
|
|
202
|
+ else
|
|
203
|
+ toList = toList.Substring(0, toList.Length - 2);
|
|
204
|
+ }
|
|
205
|
+
|
|
206
|
+ var host = _dbContext.Hosts.FirstOrDefault();
|
|
207
|
+ using (SmtpClient smtp = new SmtpClient(host.Host))
|
|
208
|
+ {
|
|
209
|
+ MailMessage mail = new MailMessage();
|
|
210
|
+ mail.To.Add(toList);
|
|
211
|
+ mail.Subject = "Uni-Vate - New Contact Request";
|
|
212
|
+ mail.Body = body;
|
|
213
|
+ mail.IsBodyHtml = true;
|
|
214
|
+ mail.BodyEncoding = Encoding.ASCII;
|
|
215
|
+ mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
|
|
216
|
+ mail.Sender = new MailAddress(host.User, "UniVate Properties");
|
|
217
|
+ mail.From = mail.Sender;
|
|
218
|
+
|
|
219
|
+ smtp.UseDefaultCredentials = host.NeedsAuthorize;
|
|
220
|
+ smtp.Credentials = host.GetNetworkCredential();
|
|
221
|
+ smtp.EnableSsl = host.UseSSL;
|
|
222
|
+ smtp.Send(mail);
|
|
223
|
+ }
|
|
224
|
+ }
|
|
225
|
+
|
|
226
|
+ public void WeekOfferMadeUser(TimeshareWeek week, BidItem bid)
|
|
227
|
+ {
|
|
228
|
+ //var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekOfferMade-User").Where(y => y.IsDeleted == false).ToList();
|
|
229
|
+
|
|
230
|
+ string body = _dbContext.Templates.Where(x => x.Name == "WeekOfferMade-User").Where(y => y.IsDeleted == false).FirstOrDefault().Body; ;
|
|
231
|
+
|
|
232
|
+ body = body.Replace("[OWNER]", week.DisplayOwner);
|
|
233
|
+ body = body.Replace("[RESORTNAME]", week.ResortName);
|
|
234
|
+ body = body.Replace("[UNITNUMBER]", week.UnitNumber);
|
|
235
|
+ body = body.Replace("[MODULE]", week.Module);
|
|
236
|
+ body = body.Replace("[OFFERMADE]", bid.Amount.ToString());
|
|
237
|
+ body = body.Replace("[FULLNAME]", bid.BidMaker.Display);
|
|
238
|
+ body = body.Replace("[USEREMAIL]", bid.BidMaker.Email);
|
|
239
|
+ body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
|
|
240
|
+ body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
|
|
241
|
+ body = body.Replace("[USERCOMMENT]", bid.Comment);
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+ var host = _dbContext.Hosts.FirstOrDefault();
|
|
246
|
+ using (SmtpClient smtp = new SmtpClient(host.Host))
|
|
247
|
+ {
|
|
248
|
+ MailMessage mail = new MailMessage();
|
|
249
|
+ mail.To.Add(bid.BidMaker.Email);
|
|
250
|
+ mail.Subject = "Uni-Vate - New Contact Request";
|
|
251
|
+ mail.Body = body;
|
|
252
|
+ mail.IsBodyHtml = true;
|
|
253
|
+ mail.BodyEncoding = Encoding.ASCII;
|
|
254
|
+ mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
|
|
255
|
+ mail.Sender = new MailAddress(host.User, "UniVate Properties");
|
|
256
|
+ mail.From = mail.Sender;
|
|
257
|
+
|
|
258
|
+ smtp.UseDefaultCredentials = host.NeedsAuthorize;
|
|
259
|
+ smtp.Credentials = host.GetNetworkCredential();
|
|
260
|
+ smtp.EnableSsl = host.UseSSL;
|
|
261
|
+ smtp.Send(mail);
|
|
262
|
+ }
|
|
263
|
+ }
|
|
264
|
+
|
|
265
|
+ public void WeekOfferMadeAdmin()
|
|
266
|
+ {
|
|
267
|
+
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ public void WeekLoadedAgent(TimeshareWeek week)
|
|
271
|
+ {
|
|
272
|
+ string body = _dbContext.Templates.Where(x => x.Name == "WeekLoaded-Agent").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
|
|
273
|
+ var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekLoaded-Agent").Where(y => y.IsDeleted == false).ToList();
|
|
274
|
+
|
|
275
|
+ body = body.Replace("[FULLNAME]", week.DisplayOwner);
|
|
276
|
+ body = body.Replace("[RESORTNAME]", week.ResortName);
|
|
277
|
+ body = body.Replace("[UNITNUMBER]", week.UnitNumber);
|
|
278
|
+ body = body.Replace("[MODULE]", week.Module);
|
|
279
|
+
|
|
280
|
+ string toList = "";
|
|
281
|
+ int emailCount = 0;
|
|
282
|
+ foreach (var recipient in recipients)
|
|
283
|
+ {
|
|
284
|
+ toList += recipient.RecipientMail + ";, ";
|
|
285
|
+ emailCount++;
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+ if (toList.Length > 0)
|
|
289
|
+ {
|
|
290
|
+ if (emailCount == 1)
|
|
291
|
+ toList = toList.Substring(0, toList.Length - 3);
|
|
292
|
+ else
|
|
293
|
+ toList = toList.Substring(0, toList.Length - 2);
|
|
294
|
+ }
|
|
295
|
+
|
|
296
|
+ var host = _dbContext.Hosts.FirstOrDefault();
|
|
297
|
+ using (SmtpClient smtp = new SmtpClient(host.Host))
|
|
298
|
+ {
|
|
299
|
+ MailMessage mail = new MailMessage();
|
|
300
|
+ mail.To.Add(toList);
|
|
301
|
+ mail.Subject = "Uni-Vate - Password Reset Request";
|
|
302
|
+ mail.Body = body;
|
|
303
|
+ mail.IsBodyHtml = true;
|
|
304
|
+ mail.BodyEncoding = Encoding.ASCII;
|
|
305
|
+ mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
|
|
306
|
+ mail.Sender = new MailAddress(host.User, "UniVate Properties");
|
|
307
|
+ mail.From = mail.Sender;
|
|
308
|
+
|
|
309
|
+ smtp.UseDefaultCredentials = host.NeedsAuthorize;
|
|
310
|
+ smtp.Credentials = host.GetNetworkCredential();
|
|
311
|
+ smtp.EnableSsl = host.UseSSL;
|
|
312
|
+ smtp.Send(mail);
|
|
313
|
+ }
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ public void WeekLoadedOwner(TimeshareWeek week)
|
|
317
|
+ {
|
|
318
|
+ string body = _dbContext.Templates.Where(x => x.Name == "WeekLoaded-Owner").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
|
|
319
|
+ var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekLoaded-Owner").Where(y => y.IsDeleted == false).ToList();
|
|
320
|
+
|
|
321
|
+ body = body.Replace("[FULLNAME]", week.DisplayOwner);
|
|
322
|
+ body = body.Replace("[RESORTNAME]", week.ResortName);
|
|
323
|
+ body = body.Replace("[UNITNUMBER]", week.UnitNumber);
|
|
324
|
+ body = body.Replace("[MODULE]", week.Module);
|
|
325
|
+
|
|
326
|
+ string toList = "";
|
|
327
|
+ int emailCount = 0;
|
|
328
|
+ foreach (var recipient in recipients)
|
|
329
|
+ {
|
|
330
|
+ toList += recipient.RecipientMail + ";, ";
|
|
331
|
+ emailCount++;
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ if (toList.Length > 0)
|
|
335
|
+ {
|
|
336
|
+ if (emailCount == 1)
|
|
337
|
+ toList = toList.Substring(0, toList.Length - 3);
|
|
338
|
+ else
|
|
339
|
+ toList = toList.Substring(0, toList.Length - 2);
|
|
340
|
+ }
|
|
341
|
+
|
|
342
|
+ var host = _dbContext.Hosts.FirstOrDefault();
|
|
343
|
+ using (SmtpClient smtp = new SmtpClient(host.Host))
|
|
344
|
+ {
|
|
345
|
+ MailMessage mail = new MailMessage();
|
|
346
|
+ mail.To.Add(toList);
|
|
347
|
+ mail.Subject = "Uni-Vate - Password Reset Request";
|
|
348
|
+ mail.Body = body;
|
|
349
|
+ mail.IsBodyHtml = true;
|
|
350
|
+ mail.BodyEncoding = Encoding.ASCII;
|
|
351
|
+ mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
|
|
352
|
+ mail.Sender = new MailAddress(host.User, "UniVate Properties");
|
|
353
|
+ mail.From = mail.Sender;
|
|
354
|
+
|
|
355
|
+ smtp.UseDefaultCredentials = host.NeedsAuthorize;
|
|
356
|
+ smtp.Credentials = host.GetNetworkCredential();
|
|
357
|
+ smtp.EnableSsl = host.UseSSL;
|
|
358
|
+ smtp.Send(mail);
|
|
359
|
+ }
|
|
360
|
+ }
|
|
361
|
+
|
188
|
362
|
public void AddRecipient(MailRecipient rec)
|
189
|
363
|
{
|
190
|
364
|
if (MyCommon.IsValidEmail(rec.RecipientMail))
|