浏览代码

Added the Enquire now to the property page

master
Lene 4 年前
父节点
当前提交
32cb08312d

+ 3
- 1
UnivateProperties_API/Controllers/Communication/MailController.cs 查看文件

@@ -29,6 +29,9 @@ namespace UnivateProperties_API.Controllers.Communication
29 29
                     case 0:
30 30
                         _repo.ContactUs(mm);
31 31
                         break;
32
+                    case 1:
33
+                        _repo.EnquireNow(mm);
34
+                        break;
32 35
                 }
33 36
                 return new OkResult();
34 37
             }
@@ -36,7 +39,6 @@ namespace UnivateProperties_API.Controllers.Communication
36 39
             {
37 40
                 return new BadRequestResult();
38 41
             }
39
-
40 42
         }
41 43
     }
42 44
 }

+ 38
- 0
UnivateProperties_API/Repository/Communication/MailRepository.cs 查看文件

@@ -7,6 +7,7 @@ namespace UnivateProperties_API.Repository.Communication
7 7
     public interface IMailRepository
8 8
     {
9 9
         void ContactUs(MailModel mm);
10
+        void EnquireNow(MailModel mm);
10 11
     }
11 12
 
12 13
     public class MailRepository : IMailRepository
@@ -55,5 +56,42 @@ namespace UnivateProperties_API.Repository.Communication
55 56
             client.Disconnect(true);
56 57
             client.Dispose();
57 58
         }
59
+
60
+        public void EnquireNow(MailModel mm)
61
+        {
62
+            string phone = mm.Phone;
63
+            string name = mm.Name;
64
+            string email = mm.Email;
65
+            string message = mm.Message;
66
+
67
+            from = new MailboxAddress("Admin", mm.FromAddress);
68
+
69
+            to = new MailboxAddress("User", mm.ToAddress);
70
+
71
+            messageObj.From.Add(from);
72
+            messageObj.To.Add(to);
73
+
74
+            messageObj.Subject = "Uni-Vate - Enquiry to view property";
75
+
76
+            bodyBuilder.HtmlBody = "<div style=\"margin: 5px\">" +
77
+                "<h4>Contact from: " + name + "!</h4>" +
78
+                "<h4>Email: " + email + "</h4>" +
79
+                "<h4>Phone: " + phone + "</h4>" +
80
+                "<div>" +
81
+                "<h4>Message: </h4>" +
82
+                "<p>" + message + "</p>" +
83
+                "</div>" +
84
+                "</div>" +
85
+                "</div>";
86
+
87
+            messageObj.Body = bodyBuilder.ToMessageBody();
88
+
89
+            client.Connect("smtp.gmail.com", 465, true);
90
+            client.Authenticate("jlouw365@gmail.com", "setskohatxpsceqo");
91
+
92
+            client.Send(messageObj);
93
+            client.Disconnect(true);
94
+            client.Dispose();
95
+        }
58 96
     }
59 97
 }

正在加载...
取消
保存