API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MailRepository.cs 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. using Abp.Specifications;
  2. using MimeKit;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Linq.Dynamic.Core;
  7. using System.Net.Mail;
  8. using System.Text;
  9. using UnivateProperties_API.Containers.Timeshare;
  10. using UnivateProperties_API.Context;
  11. using UnivateProperties_API.Helpers;
  12. using UnivateProperties_API.Model.Communication;
  13. using UnivateProperties_API.Model.ProcessFlow;
  14. using UnivateProperties_API.Model.Timeshare;
  15. using UnivateProperties_API.Model.Users;
  16. namespace UnivateProperties_API.Repository.Communication
  17. {
  18. public interface IMailRepository
  19. {
  20. void ContactUs(MailModel mm);
  21. void EnquireNow(MailModel mm);
  22. void AddRecipient(MailRecipient rec);
  23. List<MailRecipient> GetMailRecipients();
  24. MailRecipient GetMailRecipientById(int id);
  25. void UpdateMailRecipient(MailRecipient rec);
  26. void DeleteMailRecipient(int id);
  27. List<MailModel> GetEnquireNowLog();
  28. List<MailModel> GetContactUsLog();
  29. }
  30. public class MailRepository : IMailRepository
  31. {
  32. private readonly DataContext _dbContext;
  33. public MailRepository(DataContext db)
  34. {
  35. _dbContext = db;
  36. }
  37. public MailRepository()
  38. {
  39. }
  40. public void ContactUs(MailModel mm)
  41. {
  42. var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "ContactUs").Where(y => y.IsDeleted == false).ToList();
  43. string body = _dbContext.Templates.Where(x => x.Name == "ContactUs").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
  44. string error = "";
  45. body = body.Replace("[FULLNAME]", mm.Name);
  46. body = body.Replace("[USEREMAIL]", mm.Email);
  47. body = body.Replace("[USERCELLPHONE]", mm.Phone);
  48. body = body.Replace("[PROPERTYREF]", mm.Property);
  49. body = body.Replace("[USERMESSAGE]", mm.Message);
  50. string toList = "";
  51. int emailCount = 0;
  52. foreach (var recipient in recipients)
  53. {
  54. toList += recipient.RecipientMail + ", ";
  55. emailCount++;
  56. }
  57. if (toList.Length > 0)
  58. {
  59. if (emailCount == 1)
  60. toList = toList.Substring(0, toList.Length - 2);
  61. else
  62. toList = toList.Substring(0, toList.Length - 2);
  63. }
  64. try
  65. {
  66. var host = _dbContext.Hosts.FirstOrDefault();
  67. using (SmtpClient smtp = new SmtpClient(host.Host))
  68. {
  69. MailMessage mail = new MailMessage();
  70. mail.To.Add(toList);
  71. mail.Subject = "Uni-Vate - New Contact Request";
  72. mail.Body = body;
  73. mail.IsBodyHtml = true;
  74. mail.BodyEncoding = Encoding.ASCII;
  75. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  76. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  77. mail.From = new MailAddress(mm.Email, mm.Name);
  78. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  79. smtp.Credentials = host.GetNetworkCredential();
  80. smtp.EnableSsl = host.UseSSL;
  81. smtp.Send(mail);
  82. }
  83. error = "None";
  84. }
  85. catch (Exception ex)
  86. {
  87. error = ex.ToString();
  88. }
  89. mm.ComType = "Contact Us";
  90. mm.Error = error;
  91. _dbContext.CommunicationLog.Add(mm);
  92. _dbContext.SaveChanges();
  93. if (error != "None")
  94. {
  95. throw new AppException("SMTP Server Error - Please try later.");
  96. }
  97. }
  98. public void EnquireNow(MailModel mm)
  99. {
  100. var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "EnquireNow").Where(y => y.IsDeleted == false).ToList();
  101. string body = _dbContext.Templates.Where(x => x.Name == "EnquireNow").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
  102. var property = _dbContext.Properties.Where(x => x.Id == Convert.ToInt32(mm.Property)).FirstOrDefault();
  103. string error = "";
  104. body = body.Replace("[FULLNAME]", " " + mm.Name);
  105. body = body.Replace("[USEREMAIL]", " " + mm.Email);
  106. body = body.Replace("[USERCELLPHONE]", " " + mm.Phone);
  107. body = body.Replace("[PROPERTYID]", " " + mm.Property);
  108. body = body.Replace("[PROPERTYNAME]", property.PropertyName);
  109. body = body.Replace("[PROPERTYREF]", property.PropertyRef);
  110. body = body.Replace("[PROPERTYPRICE]", property.Price.ToString());
  111. body = body.Replace("[USERMESSAGE]", " " + mm.Message);
  112. body = body.Replace("[USERHEARDFROM]", " " + mm.HeardFrom);
  113. string toList = "";
  114. int emailCount = 0;
  115. foreach (var recipient in recipients)
  116. {
  117. toList += recipient.RecipientMail + ", ";
  118. emailCount++;
  119. }
  120. if (toList.Length > 0)
  121. {
  122. if (emailCount == 1)
  123. toList = toList.Substring(0, toList.Length - 2);
  124. else
  125. toList = toList.Substring(0, toList.Length - 2);
  126. }
  127. try
  128. {
  129. var host = _dbContext.Hosts.FirstOrDefault();
  130. using (SmtpClient smtp = new SmtpClient(host.Host))
  131. {
  132. MailMessage mail = new MailMessage();
  133. mail.To.Add(toList);
  134. mail.Subject = "Uni-Vate - Enquiry to view property";
  135. mail.Body = body;
  136. mail.IsBodyHtml = true;
  137. mail.BodyEncoding = Encoding.ASCII;
  138. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  139. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  140. mail.From = new MailAddress(mm.Email, mm.Name);
  141. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  142. smtp.Credentials = host.GetNetworkCredential();
  143. smtp.EnableSsl = host.UseSSL;
  144. smtp.Send(mail);
  145. }
  146. error = "None";
  147. }
  148. catch (Exception ex)
  149. {
  150. error = ex.ToString();
  151. }
  152. mm.ComType = "Enquire Now";
  153. mm.Error = error;
  154. _dbContext.CommunicationLog.Add(mm);
  155. _dbContext.SaveChanges();
  156. if (error != "None")
  157. {
  158. throw new AppException("SMTP Server Error - Please try later.");
  159. }
  160. }
  161. public void ForgotPassword(Individual toPerson, string link)
  162. {
  163. string body = "<div style=\"margin: 5px\">" +
  164. "<h4>Dear " + toPerson.FullName + "</h4>" +
  165. "<h4>There has been a request to reset your password. If this is incorrect please send an email to info@univateproperties.co.za</h4>" +
  166. "<h4>Once your password has been reset you can use the username "+ toPerson.User.Username + " and the new password to log in.</h4>" +
  167. "<div>" +
  168. "<h4><a href='" + link + "'>Click here</a> to reset your password.</h4>" +
  169. "<br />"+
  170. "<h4>Thank You</h4>" +
  171. "<h4>Team Uni-Vate</h4>" +
  172. "</div>" +
  173. "</div>";
  174. var host = _dbContext.Hosts.FirstOrDefault();
  175. using (SmtpClient smtp = new SmtpClient(host.Host))
  176. {
  177. MailMessage mail = new MailMessage();
  178. mail.To.Add(new MailAddress(toPerson.Email, toPerson.FullName));
  179. mail.Subject = "Uni-Vate - Password Reset Request";
  180. mail.Body = body;
  181. mail.IsBodyHtml = true;
  182. mail.BodyEncoding = Encoding.ASCII;
  183. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  184. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  185. mail.From = mail.Sender;
  186. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  187. smtp.Credentials = host.GetNetworkCredential();
  188. smtp.EnableSsl = host.UseSSL;
  189. smtp.Send(mail);
  190. }
  191. }
  192. public void WeekOfferMadeOwner(TimeshareWeek week, BidItem bid)
  193. {
  194. var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekOfferMade-Owner").Where(y => y.IsDeleted == false).ToList();
  195. string body = _dbContext.Templates.Where(x => x.Name == "WeekOfferMade-Owner").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
  196. body = body.Replace("[OWNER]", week.DisplayOwner);
  197. body = body.Replace("[RESORTNAME]", week.ResortName);
  198. body = body.Replace("[UNITNUMBER]", week.UnitNumber);
  199. body = body.Replace("[MODULE]", week.Module);
  200. body = body.Replace("[OFFERMADE]", bid.Amount.ToString());
  201. body = body.Replace("[FULLNAME]", bid.BidMaker.Display);
  202. body = body.Replace("[USEREMAIL]", bid.BidMaker.Email);
  203. body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
  204. body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
  205. body = body.Replace("[USERCOMMENT]", bid.Comment);
  206. string toList = "";
  207. int emailCount = 0;
  208. foreach (var recipient in recipients)
  209. {
  210. toList += recipient.RecipientMail + ", ";
  211. emailCount++;
  212. }
  213. if (toList.Length > 0)
  214. {
  215. if (emailCount == 1)
  216. toList = toList.Substring(0, toList.Length - 2);
  217. else
  218. toList = toList.Substring(0, toList.Length - 2);
  219. }
  220. var host = _dbContext.Hosts.FirstOrDefault();
  221. using (SmtpClient smtp = new SmtpClient(host.Host))
  222. {
  223. MailMessage mail = new MailMessage();
  224. mail.To.Add(toList);
  225. mail.Subject = "Uni-Vate - New Contact Request";
  226. mail.Body = body;
  227. mail.IsBodyHtml = true;
  228. mail.BodyEncoding = Encoding.ASCII;
  229. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  230. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  231. mail.From = mail.Sender;
  232. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  233. smtp.Credentials = host.GetNetworkCredential();
  234. smtp.EnableSsl = host.UseSSL;
  235. smtp.Send(mail);
  236. }
  237. }
  238. public void WeekOfferMadeUser(TimeshareWeek week, BidItem bid)
  239. {
  240. //var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekOfferMade-User").Where(y => y.IsDeleted == false).ToList();
  241. string body = _dbContext.Templates.Where(x => x.Name == "WeekOfferMade-User").Where(y => y.IsDeleted == false).FirstOrDefault().Body; ;
  242. body = body.Replace("[OWNER]", week.DisplayOwner);
  243. body = body.Replace("[RESORTNAME]", week.ResortName);
  244. body = body.Replace("[UNITNUMBER]", week.UnitNumber);
  245. body = body.Replace("[MODULE]", week.Module);
  246. body = body.Replace("[OFFERMADE]", bid.Amount.ToString());
  247. body = body.Replace("[FULLNAME]", bid.BidMaker.Display);
  248. body = body.Replace("[USEREMAIL]", bid.BidMaker.Email);
  249. body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
  250. body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
  251. body = body.Replace("[USERCOMMENT]", bid.Comment);
  252. var host = _dbContext.Hosts.FirstOrDefault();
  253. using (SmtpClient smtp = new SmtpClient(host.Host))
  254. {
  255. MailMessage mail = new MailMessage();
  256. mail.To.Add(bid.BidMaker.Email);
  257. mail.Subject = "Uni-Vate - New Contact Request";
  258. mail.Body = body;
  259. mail.IsBodyHtml = true;
  260. mail.BodyEncoding = Encoding.ASCII;
  261. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  262. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  263. mail.From = mail.Sender;
  264. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  265. smtp.Credentials = host.GetNetworkCredential();
  266. smtp.EnableSsl = host.UseSSL;
  267. smtp.Send(mail);
  268. }
  269. }
  270. public void WeekOfferMadeAdmin()
  271. {
  272. }
  273. public void WeekLoadedAgent(TimeshareWeekDto week)
  274. {
  275. string body = _dbContext.Templates.Where(x => x.Name == "WeekLoaded-Agent").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
  276. var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekLoaded-Agent").Where(y => y.IsDeleted == false).ToList();
  277. #region ResortFields
  278. body = body.Replace("[RESORTNAME]", " " + week.ResortName);
  279. body = body.Replace("[UNITNUMBER]", " " + week.UnitNumber);
  280. body = body.Replace("[MODULE]", " " + week.Module);
  281. body = body.Replace("[RESORTPRICE]", " " + week.SellPrice.ToString());
  282. body = body.Replace("[RESORTSEASON]", " " + week.Season);
  283. body = body.Replace("[RESORTREGION]", " " + week.Region.Display);
  284. body = body.Replace("[RESORTLEVY]", " " + week.LevyAmount.ToString());
  285. body = body.Replace("[OWNER]", " " + week.DisplayOwner);
  286. body = body.Replace("[SLEEPMAX]", " " + week.MaxSleep.ToString());
  287. body = body.Replace("[WEEK]", " " + week.WeekNumber);
  288. body = body.Replace("[BEDROOMS]", " " + week.Bedrooms);
  289. body = body.Replace("[ASKINGPRICE]", " " + week.AskingPrice.ToString());
  290. body = body.Replace("[ARRIVALDATE]", " " + week.ArrivalDate.ToString());
  291. body = body.Replace("[DEPARTUREDATE]", " " + week.DepartureDate.ToString());
  292. body = body.Replace("[AGENTREFER]", week.ReferedByAgent ? " Yes" : " No");
  293. body = body.Replace("[ALLLEVY]", week.LeviesPaidInFull ? " Yes" : " No");
  294. body = body.Replace("[WEEKPLACEDFORRENTAL]", week.WeekPlacedForRental ? " Yes" : " No");
  295. body = body.Replace("[ORIGINALPURCHASEDATE]", " " + week.OriginalPurchaseDate.ToString());
  296. body = body.Replace("[CUROCCUPATIONDATES]", " " + week.ArrivalDate.ToString() + " - " + week.DepartureDate.ToString());
  297. body = body.Replace("[ORIGINALPURCHASEPRICE]", " " + week.OriginalPurchasePrice.ToString());
  298. body = body.Replace("[AGENTCOMM]", " " + week.AgentCommision.ToString());
  299. #endregion
  300. #region UserFields
  301. body = body.Replace("[FULLNAME]", " " + week.DisplayOwner);
  302. body = body.Replace("[USEREMAIL]", " " + week.OwnerObject.EmailAddress);
  303. body = body.Replace("[USERCELLPHONE]", " " + week.OwnerObject.CellNumber);
  304. body = body.Replace("[USERTELEPHONE]", " " + week.OwnerObject.LandlineNumber);
  305. #endregion
  306. string toList = "";
  307. int emailCount = 0;
  308. foreach (var recipient in recipients)
  309. {
  310. toList += recipient.RecipientMail + ", ";
  311. emailCount++;
  312. }
  313. if (toList.Length > 0)
  314. {
  315. if (emailCount == 1)
  316. toList = toList.Substring(0, toList.Length - 2);
  317. else
  318. toList = toList.Substring(0, toList.Length - 2);
  319. }
  320. var host = _dbContext.Hosts.FirstOrDefault();
  321. using (SmtpClient smtp = new SmtpClient(host.Host))
  322. {
  323. MailMessage mail = new MailMessage();
  324. mail.To.Add(toList);
  325. mail.Subject = "Uni-Vate - Week Loaded by Agent";
  326. mail.Body = body;
  327. mail.IsBodyHtml = true;
  328. mail.BodyEncoding = Encoding.ASCII;
  329. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  330. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  331. mail.From = mail.Sender;
  332. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  333. smtp.Credentials = host.GetNetworkCredential();
  334. smtp.EnableSsl = host.UseSSL;
  335. smtp.Send(mail);
  336. }
  337. }
  338. public void WeekLoadedOwner(TimeshareWeekDto week)
  339. {
  340. string body = _dbContext.Templates.Where(x => x.Name == "WeekLoaded-Owner").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
  341. var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "WeekLoaded-Owner").Where(y => y.IsDeleted == false).ToList();
  342. #region ResortFields
  343. body = body.Replace("[RESORTNAME]", " " + week.ResortName);
  344. body = body.Replace("[UNITNUMBER]", " " + week.UnitNumber);
  345. body = body.Replace("[MODULE]", " " + week.Module);
  346. body = body.Replace("[RESORTPRICE]", " " + week.SellPrice.ToString());
  347. body = body.Replace("[RESORTSEASON]", " " + week.Season);
  348. body = body.Replace("[RESORTREGION]", " " + week.Region.Display);
  349. body = body.Replace("[RESORTLEVY]", " " + week.LevyAmount.ToString());
  350. body = body.Replace("[OWNER]", " " + week.DisplayOwner);
  351. body = body.Replace("[SLEEPMAX]", " " + week.MaxSleep.ToString());
  352. body = body.Replace("[WEEK]", " " + week.WeekNumber);
  353. body = body.Replace("[BEDROOMS]", " " + week.Bedrooms);
  354. body = body.Replace("[ASKINGPRICE]", " " + week.AskingPrice.ToString());
  355. body = body.Replace("[ARRIVALDATE]", " " + week.ArrivalDate.ToString());
  356. body = body.Replace("[DEPARTUREDATE]", " " + week.DepartureDate.ToString());
  357. body = body.Replace("[AGENTREFER]", week.ReferedByAgent ? " Yes" : " No");
  358. body = body.Replace("[ALLLEVY]", week.LeviesPaidInFull ? " Yes" : " No");
  359. body = body.Replace("[WEEKPLACEDFORRENTAL]", week.WeekPlacedForRental ? " Yes" : " No");
  360. body = body.Replace("[ORIGINALPURCHASEDATE]", " " + week.OriginalPurchaseDate.ToString());
  361. body = body.Replace("[CUROCCUPATIONDATES]", " " + week.ArrivalDate.ToString() + " - " + week.DepartureDate.ToString());
  362. body = body.Replace("[ORIGINALPURCHASEPRICE]", " " + week.OriginalPurchasePrice.ToString());
  363. body = body.Replace("[AGENTCOMM]", " " + week.AgentCommision.ToString());
  364. #endregion
  365. #region UserFields
  366. body = body.Replace("[FULLNAME]", " " + week.DisplayOwner );
  367. body = body.Replace("[USEREMAIL]", " " + week.OwnerObject.EmailAddress);
  368. body = body.Replace("[USERCELLPHONE]", " " + week.OwnerObject.CellNumber);
  369. body = body.Replace("[USERTELEPHONE]", " " + week.OwnerObject.LandlineNumber);
  370. #endregion
  371. string toList = "";
  372. int emailCount = 0;
  373. foreach (var recipient in recipients)
  374. {
  375. toList += recipient.RecipientMail + ", ";
  376. emailCount++;
  377. }
  378. if (toList.Length > 0)
  379. {
  380. if (emailCount == 1)
  381. toList = toList.Substring(0, toList.Length - 2);
  382. else
  383. toList = toList.Substring(0, toList.Length - 2);
  384. }
  385. var host = _dbContext.Hosts.FirstOrDefault();
  386. using (SmtpClient smtp = new SmtpClient(host.Host))
  387. {
  388. MailMessage mail = new MailMessage();
  389. mail.To.Add(toList);
  390. mail.Subject = "Uni-Vate - Week Loaded";
  391. mail.Body = body;
  392. mail.IsBodyHtml = true;
  393. mail.BodyEncoding = Encoding.ASCII;
  394. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  395. mail.Sender = new MailAddress(host.User, "UniVate Properties");
  396. mail.From = mail.Sender;
  397. smtp.UseDefaultCredentials = host.NeedsAuthorize;
  398. smtp.Credentials = host.GetNetworkCredential();
  399. smtp.EnableSsl = host.UseSSL;
  400. smtp.Send(mail);
  401. }
  402. }
  403. public void AddRecipient(MailRecipient rec)
  404. {
  405. if (MyCommon.IsValidEmail(rec.RecipientMail))
  406. {
  407. _dbContext.MailRecipients.Add(rec);
  408. _dbContext.SaveChanges();
  409. }
  410. else
  411. {
  412. throw new Exception();
  413. }
  414. }
  415. public List<MailRecipient> GetMailRecipients()
  416. {
  417. return _dbContext.MailRecipients.Where(x => x.IsDeleted == false).ToList();
  418. }
  419. public MailRecipient GetMailRecipientById(int id)
  420. {
  421. return _dbContext.MailRecipients.Where(x => x.Id == id).FirstOrDefault();
  422. }
  423. public void UpdateMailRecipient(MailRecipient rec)
  424. {
  425. var recipient = _dbContext.MailRecipients.Where(x => x.Id == rec.Id).FirstOrDefault();
  426. if (recipient.RecipientMail != rec.RecipientMail)
  427. {
  428. recipient.RecipientMail = rec.RecipientMail;
  429. }
  430. if (recipient.RecipientName != rec.RecipientName)
  431. {
  432. recipient.RecipientName = rec.RecipientName;
  433. }
  434. if (recipient.RecipientUsage != rec.RecipientUsage)
  435. {
  436. recipient.RecipientUsage = rec.RecipientUsage;
  437. }
  438. _dbContext.MailRecipients.Update(recipient);
  439. _dbContext.SaveChanges();
  440. }
  441. public void DeleteMailRecipient(int id)
  442. {
  443. var rec = _dbContext.MailRecipients.Where(x => x.Id == id).FirstOrDefault();
  444. _dbContext.MailRecipients.Remove(rec);
  445. _dbContext.SaveChanges();
  446. }
  447. public List<MailModel> GetContactUsLog()
  448. {
  449. return _dbContext.CommunicationLog.Where(x => x.ComType == "Contact Us").ToList();
  450. }
  451. public List<MailModel> GetEnquireNowLog()
  452. {
  453. return _dbContext.CommunicationLog.Where(x => x.ComType == "Enquire Now").ToList();
  454. }
  455. }
  456. }