|
1 | 1 | using BExIS.Emm.Entities.Event; |
2 | 2 | using BExIS.Emm.Services.Event; |
3 | 3 | using BExIS.IO.Transform.Output; |
| 4 | +using BExIS.Modules.EMM.UI.Helper; |
4 | 5 | using BExIS.Modules.EMM.UI.Models; |
5 | 6 | using BExIS.Security.Entities.Authorization; |
6 | 7 | using BExIS.Security.Entities.Objects; |
7 | 8 | using BExIS.Security.Services.Authorization; |
8 | 9 | using BExIS.Security.Services.Objects; |
9 | 10 | using BExIS.Security.Services.Subjects; |
| 11 | +using BExIS.Security.Services.Utilities; |
10 | 12 | using BExIS.Xml.Helpers; |
11 | 13 | using System; |
12 | 14 | using System.Collections.Generic; |
| 15 | +using System.Configuration; |
13 | 16 | using System.Data; |
14 | 17 | using System.IO; |
15 | 18 | using System.Linq; |
@@ -151,19 +154,70 @@ public ActionResult OnSelectTreeViewItem(long id) |
151 | 154 | public ActionResult MoveFromWaitingList(long id, long eventId) |
152 | 155 | { |
153 | 156 | using (EventRegistrationManager erManager = new EventRegistrationManager()) |
| 157 | + using (EventManager eventManager = new EventManager()) |
154 | 158 | { |
155 | 159 | var registration = erManager.EventRegistrationRepo.Get(a => a.Id == id).FirstOrDefault(); |
156 | 160 | if (registration.WaitingList == true) |
157 | 161 | registration.WaitingList = false; |
158 | 162 |
|
159 | 163 | erManager.UpdateEventRegistration(registration); |
| 164 | + |
| 165 | + var e = eventManager.GetEventById(eventId); |
| 166 | + SendNotification(registration.Data, e); |
| 167 | + |
160 | 168 | } |
161 | 169 |
|
162 | 170 |
|
163 | 171 |
|
164 | 172 | return RedirectToAction("OnSelectTreeViewItem", new { id = eventId }); |
165 | 173 | } |
166 | 174 |
|
| 175 | + private void SendNotification(XmlDocument data, Event e) |
| 176 | + { |
| 177 | + // todo: add not allowed / log in info to mail |
| 178 | + |
| 179 | + EmailStructure emailStructure = new EmailStructure(); |
| 180 | + emailStructure = EmailHelper.ReadFile(e.EventLanguage); |
| 181 | + |
| 182 | + string first_name = data.GetElementsByTagName(emailStructure.lableFirstName)[0].InnerText; |
| 183 | + string last_name = data.GetElementsByTagName(emailStructure.lableLastname)[0].InnerText; |
| 184 | + string email = data.GetElementsByTagName(emailStructure.lableEmail)[0].InnerText; |
| 185 | + |
| 186 | + string url = Request.Url.GetLeftPart(UriPartial.Authority); |
| 187 | + |
| 188 | + string mail_message = ""; |
| 189 | + string subject = emailStructure.removeFromWaitingListSubject + e.Name; |
| 190 | + |
| 191 | + string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "<br/><br/>" + |
| 192 | + emailStructure.removeFromWaitingList1 + e.Name + emailStructure.removeFromWaitingList2 + "<br/><br/>" + |
| 193 | + emailStructure.bodyClosing + "<br/>" + |
| 194 | + emailStructure.bodyClosingName; |
| 195 | + |
| 196 | + |
| 197 | + var es = new EmailService(); |
| 198 | + |
| 199 | + // If no explicit Reply to mail is set use the SystemEmail |
| 200 | + string replyTo = ""; |
| 201 | + if (String.IsNullOrEmpty(e.EmailReply)) |
| 202 | + { |
| 203 | + replyTo = ConfigurationManager.AppSettings["SystemEmail"]; |
| 204 | + } |
| 205 | + else |
| 206 | + { |
| 207 | + replyTo = e.EmailReply; |
| 208 | + } |
| 209 | + |
| 210 | + es.Send( |
| 211 | + subject, |
| 212 | + body, |
| 213 | + new List<string> { email }, // to |
| 214 | + new List<string> { e.EmailCC }, // CC |
| 215 | + new List<string> { ConfigurationManager.AppSettings["SystemEmail"], e.EmailBCC }, // Allways send BCC to SystemEmail + additional set |
| 216 | + new List<string> { replyTo } |
| 217 | + ); |
| 218 | + |
| 219 | + } |
| 220 | + |
167 | 221 | #endregion |
168 | 222 |
|
169 | 223 | #region Xml to DataTable |
|
0 commit comments