Browse Source

Added the Enquire now to the property page

master
Lene 4 years ago
parent
commit
32cb08312d

+ 3
- 1
UnivateProperties_API/Controllers/Communication/MailController.cs View File

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

+ 38
- 0
UnivateProperties_API/Repository/Communication/MailRepository.cs View File

7
     public interface IMailRepository
7
     public interface IMailRepository
8
     {
8
     {
9
         void ContactUs(MailModel mm);
9
         void ContactUs(MailModel mm);
10
+        void EnquireNow(MailModel mm);
10
     }
11
     }
11
 
12
 
12
     public class MailRepository : IMailRepository
13
     public class MailRepository : IMailRepository
55
             client.Disconnect(true);
56
             client.Disconnect(true);
56
             client.Dispose();
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
 }

Loading…
Cancel
Save