Skip to content

Commit 310d53e

Browse files
inform the person if they are moved to the registered list #33
1 parent c5ee653 commit 310d53e

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

Controllers/EventRegistrationResultController.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using BExIS.Emm.Entities.Event;
22
using BExIS.Emm.Services.Event;
33
using BExIS.IO.Transform.Output;
4+
using BExIS.Modules.EMM.UI.Helper;
45
using BExIS.Modules.EMM.UI.Models;
56
using BExIS.Security.Entities.Authorization;
67
using BExIS.Security.Entities.Objects;
78
using BExIS.Security.Services.Authorization;
89
using BExIS.Security.Services.Objects;
910
using BExIS.Security.Services.Subjects;
11+
using BExIS.Security.Services.Utilities;
1012
using BExIS.Xml.Helpers;
1113
using System;
1214
using System.Collections.Generic;
15+
using System.Configuration;
1316
using System.Data;
1417
using System.IO;
1518
using System.Linq;
@@ -151,19 +154,70 @@ public ActionResult OnSelectTreeViewItem(long id)
151154
public ActionResult MoveFromWaitingList(long id, long eventId)
152155
{
153156
using (EventRegistrationManager erManager = new EventRegistrationManager())
157+
using (EventManager eventManager = new EventManager())
154158
{
155159
var registration = erManager.EventRegistrationRepo.Get(a => a.Id == id).FirstOrDefault();
156160
if (registration.WaitingList == true)
157161
registration.WaitingList = false;
158162

159163
erManager.UpdateEventRegistration(registration);
164+
165+
var e = eventManager.GetEventById(eventId);
166+
SendNotification(registration.Data, e);
167+
160168
}
161169

162170

163171

164172
return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
165173
}
166174

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+
167221
#endregion
168222

169223
#region Xml to DataTable

Helper/EmailHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class EmailStructure
2424
{
2525
public string lableFirstName { get; set; }
2626
public string lableLastname { get; set; }
27+
public string lableEmail { get; set; }
2728
public string succesfullyRegisteredSubject { get; set; }
2829
public string succesfullyRegisteredMessage { get; set; }
2930
public string waitingListSubject { get; set; }
@@ -35,6 +36,10 @@ public class EmailStructure
3536
public string bodyHintToLink { get; set; }
3637
public string bodyClosing { get; set; }
3738
public string bodyClosingName { get; set; }
39+
public string removeFromWaitingListSubject { get; set; }
40+
public string removeFromWaitingList1 { get; set; }
41+
public string removeFromWaitingList2 { get; set; }
42+
3843

3944
public EmailStructure()
4045
{

Views/EventRegistration/AvailableEventsList.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</tr>
2424
</thead>
2525
<tbody>
26-
@for(int i = 0; i>Model.Count; i++)
26+
@for(int i = 0; i < Model.Count; i++)
2727
{
2828
<tr>
2929
<td>

Views/EventRegistrationResult/EventRegistrationResults.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
if (Model.WaitingListResults.Columns[c].ColumnName == "Action")
7474
{
7575
<td>
76-
@Html.ActionLink("Move to list", "MoveFromWaitingList", "EventRegistrationResult", new { id = Model.WaitingListResults.Rows[i][0], eventId = Model.EventId }, new { @class = "bx bx-grid-function"})
76+
@Html.ActionLink("Move", "MoveFromWaitingList", "EventRegistrationResult", new { id = Model.WaitingListResults.Rows[i][0], eventId = Model.EventId }, new { @class = "bx bx-grid-function"})
7777
</td>
7878
}
7979
else

0 commit comments

Comments
 (0)