From 614089c179d0cfc90f4d7fcff52f811e46d763ce Mon Sep 17 00:00:00 2001
From: Petzold
Date: Wed, 16 Feb 2022 14:52:11 +0100
Subject: [PATCH 1/8] waiting list feature #33
---
Controllers/EventController.cs | 9 ++++++-
Controllers/EventRegistrationController.cs | 5 +++-
.../EventRegistrationResultController.cs | 27 +++++++++++++++++++
Entities/BExIS.Emm.Entities/Events/Event.cs | 4 +++
.../Events/EventRegistration.cs | 3 +++
Models/EventModel.cs | 6 +++++
Models/EventRegistrationModel.cs | 3 ++-
.../Mappings/Default/Event/Event.hbm.xml | 8 ++++++
.../Default/Event/EventRegistration.hbm.xml | 4 +++
.../BExIS.Emm.Services/Event/EventManager.cs | 4 ++-
.../Event/EventRegistrationManager.cs | 9 ++++++-
Views/Event/EditEvent.cshtml | 20 +++++++++++---
12 files changed, 93 insertions(+), 9 deletions(-)
diff --git a/Controllers/EventController.cs b/Controllers/EventController.cs
index a46a175..82d0e06 100644
--- a/Controllers/EventController.cs
+++ b/Controllers/EventController.cs
@@ -118,6 +118,13 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
if (model.ImportantInformation == null)
ModelState.AddModelError("ImportantInformation", "Important information is required.");
+
+ if(model.ParticipantsLimitation == 0 && model.WaitingList == true)
+ ModelState.AddModelError("WaitingList", "You don't need a waiting list if there is no participants limitation.");
+
+ if (model.WaitingListLimitation > 0 && model.WaitingList == false)
+ ModelState.AddModelError("WaitingListLimitation", "You don't need a waiting list limitation if you dont use the waiting list.");
+
//check if schema file is uploaded
//if (attachments ==null &&model.Id == 0)
@@ -134,7 +141,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
if (model.Id == 0)
{
- Event newEvent = eManager.CreateEvent(model.Name, model.EventDate, model.ImportantInformation, model.MailInformation, model.SelectedEventLanguage, model.StartDate, model.Deadline, model.ParticipantsLimitation, model.EditAllowed, model.LogInPassword, model.EmailBCC, model.EmailCC, model.EmailReply, ms, null);
+ Event newEvent = eManager.CreateEvent(model.Name, model.EventDate, model.ImportantInformation, model.MailInformation, model.SelectedEventLanguage, model.StartDate, model.Deadline, model.ParticipantsLimitation, model.WaitingList,model.WaitingListLimitation, model.EditAllowed, model.LogInPassword, model.EmailBCC, model.EmailCC, model.EmailReply, ms, null);
newEvent = SaveFile(file, newEvent, eManager);
eManager.UpdateEvent(newEvent);
diff --git a/Controllers/EventRegistrationController.cs b/Controllers/EventRegistrationController.cs
index ed0de8a..3704d4d 100644
--- a/Controllers/EventRegistrationController.cs
+++ b/Controllers/EventRegistrationController.cs
@@ -587,8 +587,10 @@ public ActionResult Save()
///
private void CreateNewEventRegistration(Event e, XDocument data, User user, string email, string notificationType, string ref_id)
{
+ bool waitingList = false;
using (var erManager = new EventRegistrationManager())
{
+
//check Participants Limitation
if (e.ParticipantsLimitation != 0)
{
@@ -596,6 +598,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
if (countRegs >= e.ParticipantsLimitation)
{
notificationType = "succesfully_registered_waiting_list";
+ waitingList = true;
}
else
{
@@ -608,7 +611,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
}
// Save registration and send notification
- erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id);
+ erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
SendEmailNotification(notificationType, email, ref_id, data, e, user);
}
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index 185f0f6..f6f0a09 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -131,6 +131,7 @@ public ActionResult OnSelectTreeViewItem(long id)
{
EventRegistrationResultModel model = new EventRegistrationResultModel();
model.Results = GetEventResults(id);
+
model.EventId = id;
//check rights on event
@@ -177,6 +178,32 @@ private DataTable GetEventResults(long eventId)
return results;
}
+ private DataTable GetWaitingListResults(long eventId)
+ {
+ DataTable results = new DataTable();
+ results.Columns.Add("Deleted");
+
+ using (EventRegistrationManager erManager = new EventRegistrationManager())
+ {
+ List eventRegistrations = erManager.GetAllWaitingListRegsByEvent(eventId);
+
+ if (eventRegistrations.Count != 0)
+ {
+ XmlNodeReader xmlNodeReader = new XmlNodeReader(eventRegistrations[0].Data);
+ results = CreateDataTableColums(results, XElement.Load(xmlNodeReader));
+ xmlNodeReader.Dispose();
+ }
+
+ foreach (EventRegistration er in eventRegistrations)
+ {
+ XmlNodeReader xmlNodeReader = new XmlNodeReader(er.Data);
+ results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString()));
+ xmlNodeReader.Dispose();
+ }
+ }
+
+ return results;
+ }
//private DataTable GetEventRegistration(long eventId, XDocument data)
//{
// DataTable results = new DataTable();
diff --git a/Entities/BExIS.Emm.Entities/Events/Event.cs b/Entities/BExIS.Emm.Entities/Events/Event.cs
index 1c6e6e1..06e6172 100644
--- a/Entities/BExIS.Emm.Entities/Events/Event.cs
+++ b/Entities/BExIS.Emm.Entities/Events/Event.cs
@@ -29,6 +29,10 @@ public class Event : BusinessEntity
public virtual int ParticipantsLimitation { get; set; }
+ public virtual bool WaitingList { get; set; }
+
+ public virtual int WaitingListLimitation { get; set; }
+
public virtual bool EditAllowed { get; set; }
public virtual string LogInPassword { get; set; }
diff --git a/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs b/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
index 3b6e37c..42ee0b0 100644
--- a/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
+++ b/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
@@ -19,6 +19,9 @@ public class EventRegistration : BusinessEntity
public virtual string Token { get; set; }
+ public virtual bool WaitingList { get; set; }
+
+
#endregion
#region Associations
diff --git a/Models/EventModel.cs b/Models/EventModel.cs
index ad92b2d..15e2736 100644
--- a/Models/EventModel.cs
+++ b/Models/EventModel.cs
@@ -41,6 +41,12 @@ public class EventModel
[DisplayName("Participants limitation")]
public int ParticipantsLimitation { get; set; }
+ [DisplayName("Allow waiting list")]
+ public bool WaitingList { get; set; }
+
+ [DisplayName("Waiting list limitation")]
+ public int WaitingListLimitation { get; set; }
+
[DisplayName("Allow edit")]
public bool EditAllowed { get; set; }
diff --git a/Models/EventRegistrationModel.cs b/Models/EventRegistrationModel.cs
index 58e0790..8653575 100644
--- a/Models/EventRegistrationModel.cs
+++ b/Models/EventRegistrationModel.cs
@@ -12,7 +12,7 @@ namespace BExIS.Modules.EMM.UI.Models
{
///
- /// The EventRegistrationModel represent all informatio ehich are needed to handel a event registration.
+ /// The EventRegistrationModel represent all information which are needed to handel a event registration.
///
///
public class EventRegistrationModel
@@ -100,6 +100,7 @@ public class EventRegistrationResultModel
public long EventId { get; set; }
public XmlDocument Form { get; set; }
public DataTable Results { get; set; }
+ public DataTable WaitingListResults { get; set; }
public bool UserHasRights { get; set; }
public EventRegistrationResultModel()
diff --git a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
index 22c2dcf..5e443d4 100644
--- a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
+++ b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
@@ -83,6 +83,14 @@
+
+
+
+
+
+
+
+
diff --git a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
index c90a3ab..03d4588 100644
--- a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
+++ b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
@@ -31,6 +31,10 @@
+
+
+
+
diff --git a/Services/BExIS.Emm.Services/Event/EventManager.cs b/Services/BExIS.Emm.Services/Event/EventManager.cs
index fcac2f2..56eedf6 100644
--- a/Services/BExIS.Emm.Services/Event/EventManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventManager.cs
@@ -72,7 +72,7 @@ public E.Event GetEventById(long id)
///
/// Creates an EventRegistration and persists the entity in the database.
///
- public E.Event CreateEvent(string name, string eventDate, string importantInformation, string mailInformation, string eventLanguage, DateTime startDate, DateTime deadline, int participantsLimitation, bool editAllowed, string logInPassword, string emailBCC, string emailCC, string emailReply, MetadataStructure metadataStructure, string javaScriptPath)
+ public E.Event CreateEvent(string name, string eventDate, string importantInformation, string mailInformation, string eventLanguage, DateTime startDate, DateTime deadline, int participantsLimitation, bool waitingList, int waitingListLimitation, bool editAllowed, string logInPassword, string emailBCC, string emailCC, string emailReply, MetadataStructure metadataStructure, string javaScriptPath)
{
E.Event newEvent = new E.Event();
newEvent.Name = name;
@@ -84,6 +84,8 @@ public E.Event CreateEvent(string name, string eventDate, string importantInform
newEvent.StartDate = startDate;
newEvent.Deadline = deadline;
newEvent.ParticipantsLimitation = participantsLimitation;
+ newEvent.WaitingList = waitingList;
+ newEvent.WaitingListLimitation = waitingListLimitation;
newEvent.EditAllowed = editAllowed;
newEvent.LogInPassword = logInPassword;
newEvent.EmailBCC = emailBCC;
diff --git a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
index 52d319c..79bf005 100644
--- a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
@@ -58,7 +58,7 @@ protected virtual void Dispose(bool disposing)
///
/// Creates an EventRegistration and persists the entity in the database.
///
- public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e, User user, bool deleted, string token)
+ public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e, User user, bool deleted, string token, bool waitingList)
{
E.EventRegistration eventRegistration = new E.EventRegistration();
eventRegistration.Data = data;
@@ -66,6 +66,7 @@ public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e,
eventRegistration.Event = e;
eventRegistration.Person = user;
eventRegistration.Token= token;
+ eventRegistration.WaitingList = waitingList;
using (IUnitOfWork uow = this.GetUnitOfWork())
{
@@ -116,6 +117,12 @@ public E.EventRegistration UpdateEventRegistration(E.EventRegistration eventRegi
return EventRegistrationRepo.Query(a=>a.Event.Id == id).ToList();
}
+ public List GetAllWaitingListRegsByEvent(long id)
+ {
+ return EventRegistrationRepo.Query(a => a.Event.Id == id && a.WaitingList == true).ToList();
+ }
+
+
public List GetAllRegistrationsNotDeletedByEvent(long id)
{
return EventRegistrationRepo.Query(a => a.Event.Id == id && a.Deleted == false).ToList();
diff --git a/Views/Event/EditEvent.cshtml b/Views/Event/EditEvent.cshtml
index f72b7da..93086a0 100644
--- a/Views/Event/EditEvent.cshtml
+++ b/Views/Event/EditEvent.cshtml
@@ -111,10 +111,22 @@
|
@(Html.Telerik().IntegerTextBoxFor(m => m.ParticipantsLimitation)
- .MinValue(0)
- .MaxValue(Int32.MaxValue)
- .Value(Model.ParticipantsLimitation)
- .HtmlAttributes(new { tabindex = "2", style = "border-width: 2px; height: 30px;" })
+ .HtmlAttributes(new { tabindex = "2", style = "border-width: 2px; height: 30px;" })
+ )
+ |
+
+
+ | @Html.LabelFor(m => m.WaitingList) |
+ @Html.CheckBoxFor(m => m.WaitingList, new { @class = "js-switch" }) |
+
+
+ |
+ *
+ @Html.LabelFor(m => m.WaitingListLimitation)
+ |
+
+ @(Html.Telerik().IntegerTextBoxFor(m => m.WaitingListLimitation)
+ .HtmlAttributes(new { tabindex = "2", style = "border-width: 2px; height: 30px;" })
)
|
From f3ce8eb1cb3d35cab504b083b5df81de402ef00b Mon Sep 17 00:00:00 2001
From: Petzold
Date: Fri, 18 Feb 2022 14:52:13 +0100
Subject: [PATCH 2/8] waiting list feature #33
---
.../EventRegistrationResultController.cs | 25 ++++-
.../Event/EventRegistrationManager.cs | 2 +-
.../EventRegistrationResults.cshtml | 100 +++++++++++++-----
3 files changed, 94 insertions(+), 33 deletions(-)
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index f6f0a09..0e7710c 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -131,6 +131,7 @@ public ActionResult OnSelectTreeViewItem(long id)
{
EventRegistrationResultModel model = new EventRegistrationResultModel();
model.Results = GetEventResults(id);
+ model.WaitingListResults = GetWaitingListResults(id);
model.EventId = id;
@@ -147,6 +148,20 @@ public ActionResult OnSelectTreeViewItem(long id)
return View("EventRegistrationResults", model);
}
+ public ActionResult MoveFromWaitingList(long id, long eventId)
+ {
+ using (EventRegistrationManager erManager = new EventRegistrationManager())
+ {
+ var registration = erManager.EventRegistrationRepo.Get(a => a.Id == id).FirstOrDefault();
+ if (registration.WaitingList == true)
+ registration.WaitingList = false;
+
+ erManager.UpdateEventRegistration(registration);
+ }
+
+ return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
+ }
+
#endregion
#region Xml to DataTable
@@ -154,6 +169,7 @@ public ActionResult OnSelectTreeViewItem(long id)
private DataTable GetEventResults(long eventId)
{
DataTable results = new DataTable();
+ results.Columns.Add("Id");
results.Columns.Add("Deleted");
using (EventRegistrationManager erManager = new EventRegistrationManager())
@@ -170,7 +186,7 @@ private DataTable GetEventResults(long eventId)
foreach (EventRegistration er in eventRegistrations)
{
XmlNodeReader xmlNodeReader = new XmlNodeReader(er.Data);
- results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString()));
+ results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString(), er.Id));
xmlNodeReader.Dispose();
}
}
@@ -181,7 +197,9 @@ private DataTable GetEventResults(long eventId)
private DataTable GetWaitingListResults(long eventId)
{
DataTable results = new DataTable();
+ results.Columns.Add("Id");
results.Columns.Add("Deleted");
+ results.Columns.Add("Action");
using (EventRegistrationManager erManager = new EventRegistrationManager())
{
@@ -197,7 +215,7 @@ private DataTable GetWaitingListResults(long eventId)
foreach (EventRegistration er in eventRegistrations)
{
XmlNodeReader xmlNodeReader = new XmlNodeReader(er.Data);
- results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString()));
+ results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString(), er.Id));
xmlNodeReader.Dispose();
}
}
@@ -237,9 +255,10 @@ private DataTable CreateDataTableColums(DataTable dataTable, XElement x)
return dt;
}
- private DataRow AddDataRow(XElement x, DataTable dt, string deleted)
+ private DataRow AddDataRow(XElement x, DataTable dt, string deleted, long id)
{
DataRow dr = dt.NewRow();
+ dr["Id"] = id;
dr["Deleted"] = deleted;
foreach (XElement xe in x.Descendants())
{
diff --git a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
index 79bf005..0087250 100644
--- a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
@@ -114,7 +114,7 @@ public E.EventRegistration UpdateEventRegistration(E.EventRegistration eventRegi
public List GetAllRegistrationsByEvent(long id)
{
- return EventRegistrationRepo.Query(a=>a.Event.Id == id).ToList();
+ return EventRegistrationRepo.Query(a=>a.Event.Id == id && a.WaitingList == false).ToList();
}
public List GetAllWaitingListRegsByEvent(long id)
diff --git a/Views/EventRegistrationResult/EventRegistrationResults.cshtml b/Views/EventRegistrationResult/EventRegistrationResults.cshtml
index 615f6b5..aefb329 100644
--- a/Views/EventRegistrationResult/EventRegistrationResults.cshtml
+++ b/Views/EventRegistrationResult/EventRegistrationResults.cshtml
@@ -19,38 +19,79 @@
{
if (Model.UserHasRights)
{
-
-
-
- @for (int c = 0; c < Model.Results.Columns.Count; c++)
- {
- |
- @Model.Results.Columns[c].ColumnName
- |
- }
-
-
-
- @for (int i = 0; i < Model.Results.Rows.Count; i++)
- {
-
- @for (int c = 0; c < Model.Results.Columns.Count; c++)
- {
- |
- @Model.Results.Rows[i][c].ToString()
- |
-
- }
-
- }
-
-
-
-
-
+
+
+
+ @for (int c = 0; c < Model.Results.Columns.Count; c++)
+ {
+ |
+ @Model.Results.Columns[c].ColumnName
+ |
+ }
+
+
+
+ @for (int i = 0; i < Model.Results.Rows.Count; i++)
+ {
+
+ @for (int c = 0; c < Model.Results.Columns.Count; c++)
+ {
+ |
+ @Model.Results.Rows[i][c].ToString()
+ |
+
+ }
+
+ }
+
+
+
@Html.ActionLink("Export (csv)", "Export", "EventRegistrationResult", new { id = Model.EventId }, new { @class = "bx-button function" })
Delete
+
+ if (Model.WaitingListResults.Rows.Count > 0)
+ {
+ Waiting list
+
+
+
+ @for (int c = 0; c < Model.WaitingListResults.Columns.Count; c++)
+ {
+ |
+ @Model.WaitingListResults.Columns[c].ColumnName
+ |
+ }
+
+
+
+ @for (int i = 0; i < Model.WaitingListResults.Rows.Count; i++)
+ {
+
+ @for (int c = 0; c < Model.WaitingListResults.Columns.Count; c++)
+ {
+ if (Model.WaitingListResults.Columns[c].ColumnName == "Action")
+ {
+ |
+ @Html.ActionLink("Move to list", "MoveFromWaitingList", "EventRegistrationResult", new { id = Model.WaitingListResults.Rows[i][0], eventId = Model.EventId }, new { @class = "bx bx-grid-function"})
+ |
+ }
+ else
+ {
+
+ @Model.WaitingListResults.Rows[i][c].ToString()
+ |
+ }
+
+ }
+
+ }
+
+
+
+
+ }
+
}
else
{
@@ -72,6 +113,7 @@
$(document).ready(function () {
$('#regResults').DataTable();
+ $('#regWaitingListResults').DataTable();
});
From c5ee6535e19780666eadec09ffea80a60fcbb062 Mon Sep 17 00:00:00 2001
From: Petzold
Date: Thu, 24 Feb 2022 17:25:14 +0100
Subject: [PATCH 3/8] handle waiting list limitation #33
---
Controllers/EventRegistrationController.cs | 8 ++
.../EventRegistrationResultController.cs | 2 +
Models/EventRegistrationModel.cs | 61 ++++++---
.../Event/EventRegistrationManager.cs | 2 +-
.../AvailableEventsList.cshtml | 117 +++++++++---------
5 files changed, 115 insertions(+), 75 deletions(-)
diff --git a/Controllers/EventRegistrationController.cs b/Controllers/EventRegistrationController.cs
index 3704d4d..46c19f1 100644
--- a/Controllers/EventRegistrationController.cs
+++ b/Controllers/EventRegistrationController.cs
@@ -86,6 +86,14 @@ private List GetAvailableEvents(string ref_id = null)
if (today >= e.StartDate)
{
EventRegistrationModel model = new EventRegistrationModel(e);
+ model.NumberOfRegistration = erManager.GetAllRegistrationsNotDeletedByEvent(e.Id).Count;
+ model.NrOfRegistrationWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count;
+
+ if((model.NrOfRegistrationWaitingList >= e.WaitingListLimitation) && (model.NrOfRegistrationWaitingList>= e.ParticipantsLimitation) )
+ {
+ model.Closed = true;
+ }
+
//check if user already registered (if logged in)
if (user != null)
{
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index 0e7710c..ca0d509 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -159,6 +159,8 @@ public ActionResult MoveFromWaitingList(long id, long eventId)
erManager.UpdateEventRegistration(registration);
}
+
+
return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
}
diff --git a/Models/EventRegistrationModel.cs b/Models/EventRegistrationModel.cs
index 8653575..148390b 100644
--- a/Models/EventRegistrationModel.cs
+++ b/Models/EventRegistrationModel.cs
@@ -19,19 +19,50 @@ public class EventRegistrationModel
{
public EventModel Event { get; set; }
- public string Participants { get; set; } //number of participants limitation
-
- public int NumberOfRegistration { get; set; } //number of already registered participants
-
- public bool EditAllowed { get; set; } // edit allowed by user
-
- public bool AlreadyRegistered { get; set; } //user already registered, this will find out via user email
-
- public bool Deleted { get; set; } //is registration deleted by user
-
- public string AlreadyRegisteredRefId { get; set; } //Already registered RefId
-
- public string Message { get; set; } //
+ ///
+ /// Number of participants limitation
+ ///
+ public string Participants { get; set; }
+
+ ///
+ /// Number of already registered participants
+ ///
+ public int NumberOfRegistration { get; set; }
+
+ ///
+ /// Number of already registered participants on waiting list
+ ///
+ public int NrOfRegistrationWaitingList { get; set; }
+
+ ///
+ /// edit allowed by user
+ ///
+ public bool EditAllowed { get; set; }
+
+ ///
+ /// user already registered, this will find out via user email
+ ///
+ public bool AlreadyRegistered { get; set; }
+
+ ///
+ /// is registration deleted by user
+ ///
+ public bool Deleted { get; set; }
+
+ ///
+ ///true if ParticipantsLimitation and WaitingListLimitation is reached
+ ///
+ public bool Closed { get; set; }
+
+ ///
+ ///Already registered RefId
+ ///
+ public string AlreadyRegisteredRefId { get; set; }
+
+ ///
+ ///
+ ///
+ //public string Message { get; set; }
public EventRegistrationModel()
{
@@ -43,10 +74,6 @@ public EventRegistrationModel(Event e)
Event = new EventModel(e);
EditAllowed = e.EditAllowed;
- using (EventRegistrationManager erManger = new EventRegistrationManager())
- {
- NumberOfRegistration = erManger.GetAllRegistrationsNotDeletedByEvent(e.Id).Count;
- }
}
}
diff --git a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
index 0087250..cbee04a 100644
--- a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
@@ -119,7 +119,7 @@ public E.EventRegistration UpdateEventRegistration(E.EventRegistration eventRegi
public List GetAllWaitingListRegsByEvent(long id)
{
- return EventRegistrationRepo.Query(a => a.Event.Id == id && a.WaitingList == true).ToList();
+ return EventRegistrationRepo.Query(a => a.Event.Id == id && a.WaitingList == true && a.Deleted == false).ToList();
}
diff --git a/Views/EventRegistration/AvailableEventsList.cshtml b/Views/EventRegistration/AvailableEventsList.cshtml
index a9e5fb1..4dc2441 100644
--- a/Views/EventRegistration/AvailableEventsList.cshtml
+++ b/Views/EventRegistration/AvailableEventsList.cshtml
@@ -11,70 +11,68 @@
-->
}
-@{
- GridPagerStyles pagerStyles = GridPagerStyles.PageSizeDropDown;
- pagerStyles |= GridPagerStyles.NextPreviousAndNumeric;
- pagerStyles |= GridPagerStyles.Numeric;
-}
-
@ViewBag.Message
-@(Html.Telerik().Grid(Model)
- .Name("Events")
- .Columns(columns =>
- {
- columns.Template(
- @
- @if (item.AlreadyRegistered == false || item.Deleted == true)
- {
- Register
- }
-
-
- @if (item.EditAllowed && item.AlreadyRegistered == true && item.Deleted == false && item.Event.Deadline >= DateTime.Now)
+
+
+
+ | Actions |
+ Event name |
+ Deadline |
+ Participant number |
+
+
+
+ @for(int i = 0; i>Model.Count; i++)
+ {
+
+ |
+ @if (Model[i].Closed)
+ {
+ Booked out
+ }
+ else if (Model[i].AlreadyRegistered == false || Model[i].Deleted == true)
+ {
+ Register
+ }
+
+
+ @if (Model[i].EditAllowed && Model[i].AlreadyRegistered == true && Model[i].Deleted == false && Model[i].Event.Deadline >= DateTime.Now)
+ {
+
+
+
+ }
+ else if (Model[i].AlreadyRegistered == true && Model[i].Deleted == false)
{
-
-
+
+
+ }
- }
- else if (item.AlreadyRegistered == true && item.Deleted == false)
+ |
+
+ @Model[i].Event.Name
+ |
+
+ @Model[i].Event.Deadline.ToString("dd-MM-yyyy")
+ |
+
+ @Model[i].NumberOfRegistration/
+ @if(Model[i].Event.ParticipantsLimitation == 0)
+ {
+ no limitation
+ }
+ else
{
-
-
+ @Model[i].Event.ParticipantsLimitation
}
+ |
+
+ }
+
+
+
-
- ).Width(150);
- columns.Bound(r => r.Event.Name);
- columns.Bound(r => r.Event.Deadline).Format("{0: dd-MM-yyyy}").Width(200);
- columns.Template(
- @
- @item.NumberOfRegistration/
- @if (item.Event.ParticipantsLimitation == 0)
- {
- no limitation
- }
- else {
- @item.Event.ParticipantsLimitation
- }
-
- ).Width(150);
- //columns.Bound(r => r.Event.ParticipantsLimitation);
- })
- .Pageable(paging =>
- paging
- .Style(pagerStyles)
- .PageSize(50)
- .Position(GridPagerPosition.Both)
- )
- .Filterable()
- //.Sortable(sortable => sortable
- // .OrderBy(orderby => orderby
- // .Add(r => r.Id).Descending()))
-)
@(Html.Telerik().Window()
.Name("Window_LogInToEvent")
.Title("Event registration")
@@ -99,6 +97,11 @@
//addTooltips();
//}
+ $(document).ready(function () {
+ $('#events').DataTable();
+
+ });
+
function onClickRegister(id)
{
From 310d53e37cddeb076b7acbe0e38028369589a120 Mon Sep 17 00:00:00 2001
From: Petzold
Date: Thu, 3 Mar 2022 08:53:10 +0100
Subject: [PATCH 4/8] inform the person if they are moved to the registered
list #33
---
.../EventRegistrationResultController.cs | 54 +++++++++++++++++++
Helper/EmailHelper.cs | 5 ++
.../AvailableEventsList.cshtml | 2 +-
.../EventRegistrationResults.cshtml | 2 +-
4 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index ca0d509..1c75112 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -1,15 +1,18 @@
using BExIS.Emm.Entities.Event;
using BExIS.Emm.Services.Event;
using BExIS.IO.Transform.Output;
+using BExIS.Modules.EMM.UI.Helper;
using BExIS.Modules.EMM.UI.Models;
using BExIS.Security.Entities.Authorization;
using BExIS.Security.Entities.Objects;
using BExIS.Security.Services.Authorization;
using BExIS.Security.Services.Objects;
using BExIS.Security.Services.Subjects;
+using BExIS.Security.Services.Utilities;
using BExIS.Xml.Helpers;
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
@@ -151,12 +154,17 @@ public ActionResult OnSelectTreeViewItem(long id)
public ActionResult MoveFromWaitingList(long id, long eventId)
{
using (EventRegistrationManager erManager = new EventRegistrationManager())
+ using (EventManager eventManager = new EventManager())
{
var registration = erManager.EventRegistrationRepo.Get(a => a.Id == id).FirstOrDefault();
if (registration.WaitingList == true)
registration.WaitingList = false;
erManager.UpdateEventRegistration(registration);
+
+ var e = eventManager.GetEventById(eventId);
+ SendNotification(registration.Data, e);
+
}
@@ -164,6 +172,52 @@ public ActionResult MoveFromWaitingList(long id, long eventId)
return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
}
+ private void SendNotification(XmlDocument data, Event e)
+ {
+ // todo: add not allowed / log in info to mail
+
+ EmailStructure emailStructure = new EmailStructure();
+ emailStructure = EmailHelper.ReadFile(e.EventLanguage);
+
+ string first_name = data.GetElementsByTagName(emailStructure.lableFirstName)[0].InnerText;
+ string last_name = data.GetElementsByTagName(emailStructure.lableLastname)[0].InnerText;
+ string email = data.GetElementsByTagName(emailStructure.lableEmail)[0].InnerText;
+
+ string url = Request.Url.GetLeftPart(UriPartial.Authority);
+
+ string mail_message = "";
+ string subject = emailStructure.removeFromWaitingListSubject + e.Name;
+
+ string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
+ emailStructure.removeFromWaitingList1 + e.Name + emailStructure.removeFromWaitingList2 + "
" +
+ emailStructure.bodyClosing + "
" +
+ emailStructure.bodyClosingName;
+
+
+ var es = new EmailService();
+
+ // If no explicit Reply to mail is set use the SystemEmail
+ string replyTo = "";
+ if (String.IsNullOrEmpty(e.EmailReply))
+ {
+ replyTo = ConfigurationManager.AppSettings["SystemEmail"];
+ }
+ else
+ {
+ replyTo = e.EmailReply;
+ }
+
+ es.Send(
+ subject,
+ body,
+ new List { email }, // to
+ new List { e.EmailCC }, // CC
+ new List { ConfigurationManager.AppSettings["SystemEmail"], e.EmailBCC }, // Allways send BCC to SystemEmail + additional set
+ new List { replyTo }
+ );
+
+ }
+
#endregion
#region Xml to DataTable
diff --git a/Helper/EmailHelper.cs b/Helper/EmailHelper.cs
index 426fff0..1217306 100644
--- a/Helper/EmailHelper.cs
+++ b/Helper/EmailHelper.cs
@@ -24,6 +24,7 @@ public class EmailStructure
{
public string lableFirstName { get; set; }
public string lableLastname { get; set; }
+ public string lableEmail { get; set; }
public string succesfullyRegisteredSubject { get; set; }
public string succesfullyRegisteredMessage { get; set; }
public string waitingListSubject { get; set; }
@@ -35,6 +36,10 @@ public class EmailStructure
public string bodyHintToLink { get; set; }
public string bodyClosing { get; set; }
public string bodyClosingName { get; set; }
+ public string removeFromWaitingListSubject { get; set; }
+ public string removeFromWaitingList1 { get; set; }
+ public string removeFromWaitingList2 { get; set; }
+
public EmailStructure()
{
diff --git a/Views/EventRegistration/AvailableEventsList.cshtml b/Views/EventRegistration/AvailableEventsList.cshtml
index 4dc2441..61e8e2a 100644
--- a/Views/EventRegistration/AvailableEventsList.cshtml
+++ b/Views/EventRegistration/AvailableEventsList.cshtml
@@ -23,7 +23,7 @@
- @for(int i = 0; i>Model.Count; i++)
+ @for(int i = 0; i < Model.Count; i++)
{
|
diff --git a/Views/EventRegistrationResult/EventRegistrationResults.cshtml b/Views/EventRegistrationResult/EventRegistrationResults.cshtml
index aefb329..eebf3ea 100644
--- a/Views/EventRegistrationResult/EventRegistrationResults.cshtml
+++ b/Views/EventRegistrationResult/EventRegistrationResults.cshtml
@@ -73,7 +73,7 @@
if (Model.WaitingListResults.Columns[c].ColumnName == "Action")
{
|
- @Html.ActionLink("Move to list", "MoveFromWaitingList", "EventRegistrationResult", new { id = Model.WaitingListResults.Rows[i][0], eventId = Model.EventId }, new { @class = "bx bx-grid-function"})
+ @Html.ActionLink("Move", "MoveFromWaitingList", "EventRegistrationResult", new { id = Model.WaitingListResults.Rows[i][0], eventId = Model.EventId }, new { @class = "bx bx-grid-function"})
|
}
else
From 6c085193b65069257a4c175eef0f22af7ef382bc Mon Sep 17 00:00:00 2001
From: Petzold
Date: Thu, 3 Mar 2022 11:32:59 +0100
Subject: [PATCH 5/8] Replace telerik data tables with jquery datatables done
close #90
---
Views/Event/EventManager.cshtml | 140 ++++++------------
.../AvailableEventsList.cshtml | 7 -
2 files changed, 45 insertions(+), 102 deletions(-)
diff --git a/Views/Event/EventManager.cshtml b/Views/Event/EventManager.cshtml
index 91f6601..24dc8a5 100644
--- a/Views/Event/EventManager.cshtml
+++ b/Views/Event/EventManager.cshtml
@@ -1,5 +1,4 @@
-@using Telerik.Web.Mvc.UI
-@using BExIS.Modules.EMM.UI.Models;
+@using BExIS.Modules.EMM.UI.Models;
@model List
@@ -11,106 +10,57 @@
}
-@{
- GridPagerStyles pagerStyles = GridPagerStyles.PageSizeDropDown;
- pagerStyles |= GridPagerStyles.NextPreviousAndNumeric;
- pagerStyles |= GridPagerStyles.Numeric;
-}
-
@Html.ActionLink("Create new Event", "Create", "Event", new { @class = "bx-button function" })
-@(Html.Telerik().Grid(Model)
- .Name("Grid_Event")
- .DataKeys(keys =>
- {
- keys.Add(r => r.Id);
- })
- .Columns(columns =>
- {
-
- columns.Bound(r => r.Id).Width(90);
- columns.Bound(r => r.Name);
- columns.Bound(r => r.ParticipantsLimitation) ;
- columns.Bound(r => r.StartDate).Format("{0: dd-MM-yyyy}");
- columns.Bound(r => r.Deadline).Format("{0: dd-MM-yyyy}"); ;
- columns.Bound(r => r.EditAllowed);
- columns.Template(
- @
- @if (!item.InUse)
- {
-
-
- }
- else
- {
-
- }
+
+
+
+
+ | Id |
+ Event name |
+ Participants limitation |
+ Start date |
+ Deadline |
+ Allow edit |
+ Actions |
+
+
+
+ @for (int i = 0; i < Model.Count; i++)
+ {
+
+ | @Model[i].Id |
+ @Model[i].Name |
+ @Model[i].ParticipantsLimitation |
+ @Model[i].StartDate.ToString("dd-MM-yyyy") |
+ @Model[i].Deadline.ToString("dd-MM-yyyy") |
+
+ @if (Model[i].EditAllowed)
+ {
+
+ }
+ else
+ {
+
+ }
-
- ).Title(" ")
- .ClientTemplate(
- "" +
- " \">" +
- " " +
- " " +
- " " +
- " " +
- " " +
- " "
+ |
+
+
+
+ |
+
+ }
+
- ).Width(90);
- })
- .ClientEvents(clientevents => clientevents
- .OnDataBound("onDataBound")
- )
- .DataBinding(databinding => databinding
- .Ajax()
- .Select("AllEvents", "Event")
- )
- .Pageable(paging =>
- paging
- .Style(pagerStyles)
- .PageSize(50)
- .Position(GridPagerPosition.Both)
- )
- .Filterable()
- .Sortable(sortable => sortable
- .OrderBy(orderby => orderby
- .Add(r => r.Deadline).Descending()))
-)
+
\ No newline at end of file
+
diff --git a/Views/EventRegistration/AvailableEventsList.cshtml b/Views/EventRegistration/AvailableEventsList.cshtml
index 61e8e2a..8f3818b 100644
--- a/Views/EventRegistration/AvailableEventsList.cshtml
+++ b/Views/EventRegistration/AvailableEventsList.cshtml
@@ -92,11 +92,6 @@
From f5207b7146cc83e9a0d489e811b6d9a79f68e239 Mon Sep 17 00:00:00 2001
From: Petzold
Date: Tue, 8 Mar 2022 09:34:12 +0100
Subject: [PATCH 6/8] Closing handling #33
---
Controllers/EventController.cs | 7 ++--
Controllers/EventRegistrationController.cs | 36 +++++++++++++------
.../EventRegistrationResultController.cs | 2 --
Entities/BExIS.Emm.Entities/Events/Event.cs | 2 ++
Models/EventModel.cs | 4 +++
.../Mappings/Default/Event/Event.hbm.xml | 4 +++
.../BExIS.Emm.Services/Event/EventManager.cs | 3 +-
Views/Event/EditEvent.cshtml | 4 +++
8 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/Controllers/EventController.cs b/Controllers/EventController.cs
index 82d0e06..82c3c92 100644
--- a/Controllers/EventController.cs
+++ b/Controllers/EventController.cs
@@ -141,7 +141,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
if (model.Id == 0)
{
- Event newEvent = eManager.CreateEvent(model.Name, model.EventDate, model.ImportantInformation, model.MailInformation, model.SelectedEventLanguage, model.StartDate, model.Deadline, model.ParticipantsLimitation, model.WaitingList,model.WaitingListLimitation, model.EditAllowed, model.LogInPassword, model.EmailBCC, model.EmailCC, model.EmailReply, ms, null);
+ Event newEvent = eManager.CreateEvent(model.Name, model.EventDate, model.ImportantInformation, model.MailInformation, model.SelectedEventLanguage, model.StartDate, model.Deadline, model.ParticipantsLimitation, model.WaitingList,model.WaitingListLimitation, model.EditAllowed, model.Closed, model.LogInPassword, model.EmailBCC, model.EmailCC, model.EmailReply, ms, null);
newEvent = SaveFile(file, newEvent, eManager);
eManager.UpdateEvent(newEvent);
@@ -179,7 +179,10 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
e.StartDate = model.StartDate;
e.Deadline = model.Deadline;
e.ParticipantsLimitation = model.ParticipantsLimitation;
+ e.WaitingList = model.WaitingList;
+ e.WaitingListLimitation = model.WaitingListLimitation;
e.EditAllowed = model.EditAllowed;
+ e.Closed = model.Closed;
e.LogInPassword = model.LogInPassword;
e.LogInPassword = model.LogInPassword;
e.EmailCC = model.EmailCC;
@@ -191,7 +194,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
eManager.UpdateEvent(e);
}
- return View("EventManager");
+ return RedirectToAction("EventManager");
}
}
else
diff --git a/Controllers/EventRegistrationController.cs b/Controllers/EventRegistrationController.cs
index 46c19f1..d955b00 100644
--- a/Controllers/EventRegistrationController.cs
+++ b/Controllers/EventRegistrationController.cs
@@ -89,10 +89,7 @@ private List GetAvailableEvents(string ref_id = null)
model.NumberOfRegistration = erManager.GetAllRegistrationsNotDeletedByEvent(e.Id).Count;
model.NrOfRegistrationWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count;
- if((model.NrOfRegistrationWaitingList >= e.WaitingListLimitation) && (model.NrOfRegistrationWaitingList>= e.ParticipantsLimitation) )
- {
- model.Closed = true;
- }
+ model.Closed = e.Closed;
//check if user already registered (if logged in)
if (user != null)
@@ -583,7 +580,6 @@ public ActionResult Save()
else
CreateNewEventRegistration(e, data, user, email, notificationType, ref_id);
-
return Json(new { result = "redirect", url = Url.Action("EventRegistration", "EventRegistration", new { area = "EMM", ref_id = ref_id }) }, JsonRequestBehavior.AllowGet);
}
}
@@ -597,16 +593,34 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
{
bool waitingList = false;
using (var erManager = new EventRegistrationManager())
+ using(var eventManager = new EventManager())
{
-
//check Participants Limitation
if (e.ParticipantsLimitation != 0)
{
int countRegs = erManager.GetNumerOfRegistrationsByEvent(e.Id);
+ int countWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count + 1;
+
if (countRegs >= e.ParticipantsLimitation)
{
- notificationType = "succesfully_registered_waiting_list";
- waitingList = true;
+ if(e.WaitingList && !e.Closed)
+ {
+ if(countWaitingList == e.WaitingListLimitation)
+ {
+ e.Closed = true;
+ eventManager.UpdateEvent(e);
+ }
+
+ notificationType = "succesfully_registered_waiting_list";
+ waitingList = true;
+
+ }
+ else
+ {
+ e.Closed = true;
+ eventManager.UpdateEvent(e);
+ notificationType = "succesfully_registered";
+ }
}
else
{
@@ -618,10 +632,10 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
notificationType = "succesfully_registered";
}
- // Save registration and send notification
- erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
+ // Save registration and send notification
+ erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
- SendEmailNotification(notificationType, email, ref_id, data, e, user);
+ SendEmailNotification(notificationType, email, ref_id, data, e, user);
}
}
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index 1c75112..e8cdfa8 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -167,8 +167,6 @@ public ActionResult MoveFromWaitingList(long id, long eventId)
}
-
-
return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
}
diff --git a/Entities/BExIS.Emm.Entities/Events/Event.cs b/Entities/BExIS.Emm.Entities/Events/Event.cs
index 06e6172..c510a06 100644
--- a/Entities/BExIS.Emm.Entities/Events/Event.cs
+++ b/Entities/BExIS.Emm.Entities/Events/Event.cs
@@ -35,6 +35,8 @@ public class Event : BusinessEntity
public virtual bool EditAllowed { get; set; }
+ public virtual bool Closed { get; set; }
+
public virtual string LogInPassword { get; set; }
public virtual string EmailBCC { get; set; }
diff --git a/Models/EventModel.cs b/Models/EventModel.cs
index 15e2736..fa0869b 100644
--- a/Models/EventModel.cs
+++ b/Models/EventModel.cs
@@ -50,6 +50,7 @@ public class EventModel
[DisplayName("Allow edit")]
public bool EditAllowed { get; set; }
+ public bool Closed { get; set; }
public bool EditMode { get; set; }
[DisplayName("Event password")]
@@ -103,6 +104,9 @@ public EventModel(Event eEvent)
StartDate = eEvent.StartDate;
Deadline = eEvent.Deadline;
ParticipantsLimitation = eEvent.ParticipantsLimitation;
+ WaitingList = eEvent.WaitingList;
+ WaitingListLimitation = eEvent.WaitingListLimitation;
+ Closed = eEvent.Closed;
//if (eEvent.ParticipantsLimitation == 0)
// ParticipantsLimitation = "no limitation";
diff --git a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
index 5e443d4..5d50712 100644
--- a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
+++ b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml
@@ -95,6 +95,10 @@
+
+
+
+
diff --git a/Services/BExIS.Emm.Services/Event/EventManager.cs b/Services/BExIS.Emm.Services/Event/EventManager.cs
index 56eedf6..68cd3ee 100644
--- a/Services/BExIS.Emm.Services/Event/EventManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventManager.cs
@@ -72,7 +72,7 @@ public E.Event GetEventById(long id)
///
/// Creates an EventRegistration and persists the entity in the database.
///
- public E.Event CreateEvent(string name, string eventDate, string importantInformation, string mailInformation, string eventLanguage, DateTime startDate, DateTime deadline, int participantsLimitation, bool waitingList, int waitingListLimitation, bool editAllowed, string logInPassword, string emailBCC, string emailCC, string emailReply, MetadataStructure metadataStructure, string javaScriptPath)
+ public E.Event CreateEvent(string name, string eventDate, string importantInformation, string mailInformation, string eventLanguage, DateTime startDate, DateTime deadline, int participantsLimitation, bool waitingList, int waitingListLimitation, bool editAllowed, bool closed, string logInPassword, string emailBCC, string emailCC, string emailReply, MetadataStructure metadataStructure, string javaScriptPath)
{
E.Event newEvent = new E.Event();
newEvent.Name = name;
@@ -87,6 +87,7 @@ public E.Event CreateEvent(string name, string eventDate, string importantInform
newEvent.WaitingList = waitingList;
newEvent.WaitingListLimitation = waitingListLimitation;
newEvent.EditAllowed = editAllowed;
+ newEvent.Closed = closed;
newEvent.LogInPassword = logInPassword;
newEvent.EmailBCC = emailBCC;
newEvent.EmailCC = emailCC;
diff --git a/Views/Event/EditEvent.cshtml b/Views/Event/EditEvent.cshtml
index 93086a0..5fe1335 100644
--- a/Views/Event/EditEvent.cshtml
+++ b/Views/Event/EditEvent.cshtml
@@ -194,6 +194,10 @@
@Html.ValidationMessage("EmailReply")
+
+ | @Html.LabelFor(m => m.Closed) |
+ @Html.CheckBoxFor(m => m.Closed, new { @class = "js-switch" }) |
+
From 1179d63724456b857b9934939e8616251c5c473f Mon Sep 17 00:00:00 2001
From: Petzold
Date: Tue, 8 Mar 2022 14:56:13 +0100
Subject: [PATCH 7/8] move from waiting list #33
---
Controllers/EventRegistrationController.cs | 68 ++++++++++++++++++-
.../Events/EventRegistration.cs | 2 +
.../Default/Event/EventRegistration.hbm.xml | 4 ++
.../Event/EventRegistrationManager.cs | 10 ++-
4 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/Controllers/EventRegistrationController.cs b/Controllers/EventRegistrationController.cs
index d955b00..7a1a1ba 100644
--- a/Controllers/EventRegistrationController.cs
+++ b/Controllers/EventRegistrationController.cs
@@ -498,6 +498,8 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
{
reg.Deleted = true;
erManager.UpdateEventRegistration(reg);
+ MoveFromWaitingList(reg.Event.Id);
+
}
}
else if (ref_id != null)
@@ -507,6 +509,7 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
{
reg.Deleted = true;
erManager.UpdateEventRegistration(reg);
+ MoveFromWaitingList(reg.Event.Id);
}
}
}
@@ -514,6 +517,69 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
return Json(new { result = "redirect", url = Url.Action("EventRegistration", "EventRegistration", new { area = "EMM" }) }, JsonRequestBehavior.AllowGet);
}
+ private void MoveFromWaitingList(long eventId)
+ {
+ using (var erManager = new EventRegistrationManager())
+ using (var eventManager = new EventManager())
+ {
+ int countWaitingList = erManager.GetAllWaitingListRegsByEvent(eventId).Count;
+ if (countWaitingList > 0)
+ {
+ var reg = erManager.GetLatestWaitingListEntry(eventId);
+ reg.WaitingList = false;
+ erManager.UpdateEventRegistration(reg);
+ var e = eventManager.GetEventById(eventId);
+ SendWaitingListNotification(reg.Data, e);
+ }
+ }
+ }
+
+ private void SendWaitingListNotification(XmlDocument data, Event e)
+ {
+ // todo: add not allowed / log in info to mail
+
+ EmailStructure emailStructure = new EmailStructure();
+ emailStructure = EmailHelper.ReadFile(e.EventLanguage);
+
+ string first_name = data.GetElementsByTagName(emailStructure.lableFirstName)[0].InnerText;
+ string last_name = data.GetElementsByTagName(emailStructure.lableLastname)[0].InnerText;
+ string email = data.GetElementsByTagName(emailStructure.lableEmail)[0].InnerText;
+
+ string url = Request.Url.GetLeftPart(UriPartial.Authority);
+
+ string mail_message = "";
+ string subject = emailStructure.removeFromWaitingListSubject + e.Name;
+
+ string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
+ emailStructure.removeFromWaitingList1 + e.Name + emailStructure.removeFromWaitingList2 + "
" +
+ emailStructure.bodyClosing + "
" +
+ emailStructure.bodyClosingName;
+
+
+ var es = new EmailService();
+
+ // If no explicit Reply to mail is set use the SystemEmail
+ string replyTo = "";
+ if (String.IsNullOrEmpty(e.EmailReply))
+ {
+ replyTo = ConfigurationManager.AppSettings["SystemEmail"];
+ }
+ else
+ {
+ replyTo = e.EmailReply;
+ }
+
+ es.Send(
+ subject,
+ body,
+ new List { email }, // to
+ new List { e.EmailCC }, // CC
+ new List { ConfigurationManager.AppSettings["SystemEmail"], e.EmailBCC }, // Allways send BCC to SystemEmail + additional set
+ new List { replyTo }
+ );
+
+ }
+
public ActionResult Save()
{
using (EventManager eManager = new EventManager())
@@ -633,7 +699,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
}
// Save registration and send notification
- erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
+ erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList, DateTime.Now);
SendEmailNotification(notificationType, email, ref_id, data, e, user);
}
diff --git a/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs b/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
index 42ee0b0..ff00440 100644
--- a/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
+++ b/Entities/BExIS.Emm.Entities/Events/EventRegistration.cs
@@ -21,6 +21,8 @@ public class EventRegistration : BusinessEntity
public virtual bool WaitingList { get; set; }
+ public virtual DateTime InsertDate { get; set; }
+
#endregion
diff --git a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
index 03d4588..ced7524 100644
--- a/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
+++ b/Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml
@@ -35,6 +35,10 @@
+
+
+
+
diff --git a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
index cbee04a..617087f 100644
--- a/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
+++ b/Services/BExIS.Emm.Services/Event/EventRegistrationManager.cs
@@ -58,7 +58,7 @@ protected virtual void Dispose(bool disposing)
///
/// Creates an EventRegistration and persists the entity in the database.
///
- public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e, User user, bool deleted, string token, bool waitingList)
+ public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e, User user, bool deleted, string token, bool waitingList, DateTime insertDate)
{
E.EventRegistration eventRegistration = new E.EventRegistration();
eventRegistration.Data = data;
@@ -67,6 +67,7 @@ public E.EventRegistration CreateEventRegistration(XmlDocument data, E.Event e,
eventRegistration.Person = user;
eventRegistration.Token= token;
eventRegistration.WaitingList = waitingList;
+ eventRegistration.InsertDate = insertDate;
using (IUnitOfWork uow = this.GetUnitOfWork())
{
@@ -122,6 +123,13 @@ public E.EventRegistration UpdateEventRegistration(E.EventRegistration eventRegi
return EventRegistrationRepo.Query(a => a.Event.Id == id && a.WaitingList == true && a.Deleted == false).ToList();
}
+ public E.EventRegistration GetLatestWaitingListEntry(long id)
+ {
+ var lastestDates = EventRegistrationRepo.Query(d=>d.Event.Id == id && d.WaitingList == true).ToList();
+ var date = lastestDates.Max(a => a.InsertDate);
+ return EventRegistrationRepo.Query(a => a.Event.Id == id && a.WaitingList == true && a.InsertDate == date).FirstOrDefault();
+ }
+
public List GetAllRegistrationsNotDeletedByEvent(long id)
{
From 5108df53204c0dc75c11a236df14540b87d86139 Mon Sep 17 00:00:00 2001
From: Petzold
Date: Thu, 24 Mar 2022 11:56:39 +0100
Subject: [PATCH 8/8] Send mail for delete registration done and close #95
---
Controllers/EventRegistrationController.cs | 52 +++++++++++--------
.../EventRegistrationResultController.cs | 2 +-
Helper/EmailHelper.cs | 3 +-
3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/Controllers/EventRegistrationController.cs b/Controllers/EventRegistrationController.cs
index 7a1a1ba..8a5de72 100644
--- a/Controllers/EventRegistrationController.cs
+++ b/Controllers/EventRegistrationController.cs
@@ -487,6 +487,7 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
using (SubjectManager subManager = new SubjectManager())
{
using (EventRegistrationManager erManager = new EventRegistrationManager())
+ using (var eventManager = new EventManager())
{
User user = subManager.Subjects.Where(a => a.Name == HttpContext.User.Identity.Name).FirstOrDefault() as User;
if (user != null)
@@ -500,6 +501,7 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
erManager.UpdateEventRegistration(reg);
MoveFromWaitingList(reg.Event.Id);
+ SendEmailNotification("deleted", user.Email, ref_id, reg.Data, reg.Event, user);
}
}
else if (ref_id != null)
@@ -510,9 +512,15 @@ public ActionResult DeleteRegistration(string id, string ref_id = null)
reg.Deleted = true;
erManager.UpdateEventRegistration(reg);
MoveFromWaitingList(reg.Event.Id);
+
+ SendEmailNotification("deleted", user.Email, ref_id, reg.Data, reg.Event, user);
}
}
}
+
+
+
+
}
return Json(new { result = "redirect", url = Url.Action("EventRegistration", "EventRegistration", new { area = "EMM" }) }, JsonRequestBehavior.AllowGet);
}
@@ -551,7 +559,7 @@ private void SendWaitingListNotification(XmlDocument data, Event e)
string subject = emailStructure.removeFromWaitingListSubject + e.Name;
string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
- emailStructure.removeFromWaitingList1 + e.Name + emailStructure.removeFromWaitingList2 + "
" +
+ emailStructure.removeFromWaitingList1 + "
" +
emailStructure.bodyClosing + "
" +
emailStructure.bodyClosingName;
@@ -630,14 +638,14 @@ public ActionResult Save()
{
if (e.EditAllowed != true)
{
- SendEmailNotification("resend", email, ref_id, data, e, user);
+ SendEmailNotification("resend", email, ref_id, XmlMetadataWriter.ToXmlDocument(data), e, user);
return RedirectToAction("EventRegistrationPatial", new { message = "Update of your previous registration is not allowed. You registration details are send to your Email adress again.", message_type = "error" });
}
reg.Data = XmlMetadataWriter.ToXmlDocument(data);
erManager.UpdateEventRegistration(reg);
- SendEmailNotification("updated", email, ref_id, data, e, user);
+ SendEmailNotification("updated", email, ref_id, XmlMetadataWriter.ToXmlDocument(data), e, user);
}
else
CreateNewEventRegistration(e, data, user, email, notificationType, ref_id);
@@ -664,7 +672,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
//check Participants Limitation
if (e.ParticipantsLimitation != 0)
{
- int countRegs = erManager.GetNumerOfRegistrationsByEvent(e.Id);
+ int countRegs = erManager.GetNumerOfRegistrationsByEvent(e.Id) + 1;
int countWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count + 1;
if (countRegs >= e.ParticipantsLimitation)
@@ -701,7 +709,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
// Save registration and send notification
erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList, DateTime.Now);
- SendEmailNotification(notificationType, email, ref_id, data, e, user);
+ SendEmailNotification(notificationType, email, ref_id, XmlMetadataWriter.ToXmlDocument(data), e, user);
}
}
@@ -1168,19 +1176,15 @@ private EventRegistration CheckEventRegistration(User user, string ref_id, long
}
}
- private void SendEmailNotification(string notificationType, string email, string ref_id, XDocument data, Event e, User user)
+ private void SendEmailNotification(string notificationType, string email, string ref_id, XmlDocument data, Event e, User user)
{
// todo: add not allowed / log in info to mail
- //temp for alb symosium
EmailStructure emailStructure = new EmailStructure();
- if(e.Id == 12)
- emailStructure = EmailHelper.ReadFile("English");
- else
- emailStructure = EmailHelper.ReadFile(e.EventLanguage);
+ emailStructure = EmailHelper.ReadFile(e.EventLanguage);
- string first_name = XmlMetadataWriter.ToXmlDocument(data).GetElementsByTagName(emailStructure.lableFirstName)[0].InnerText;
- string last_name = XmlMetadataWriter.ToXmlDocument(data).GetElementsByTagName(emailStructure.lableLastname)[0].InnerText;
+ string first_name = data.GetElementsByTagName(emailStructure.lableFirstName)[0].InnerText;
+ string last_name = data.GetElementsByTagName(emailStructure.lableLastname)[0].InnerText;
string url = Request.Url.GetLeftPart(UriPartial.Authority);
@@ -1201,6 +1205,10 @@ private void SendEmailNotification(string notificationType, string email, string
subject = emailStructure.updateSubject + e.Name;
mail_message = emailStructure.updateMessage + e.Name + ".
";
break;
+ case "deleted":
+ subject = emailStructure.deletedSubject + e.Name;
+ mail_message = emailStructure.deletedMessage + e.Name + ".
";
+ break;
//case "resend":
// subject = "Resend of registration confirmation for " + e.Name;
// mail_message = "your registration for " + e.Name + "
";
@@ -1209,7 +1217,8 @@ private void SendEmailNotification(string notificationType, string email, string
string details = "";
//read xml file and format email output
- foreach (XElement xe in XElement.Parse(data.ToString()).Elements())
+ XDocument xDocument = XDocument.Parse(data.OuterXml);
+ foreach (XElement xe in XElement.Parse(xDocument.ToString()).Elements())
{
string displayNameRoot = "";
if (xe.HasElements)
@@ -1233,14 +1242,15 @@ private void SendEmailNotification(string notificationType, string email, string
}
}
- string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
+ string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
- mail_message + "
" +
- e.MailInformation + "
" +
- "
" + emailStructure.bodyOpening +"
" +
- details + "
" +
- emailStructure.bodyHintToLink + url + "/emm/EventRegistration/EventRegistration/?ref_id=" + ref_id + "
" +
- emailStructure.bodyClosing + "
" +
+ mail_message + "
" +
+ e.MailInformation + "
" +
+ "
" + emailStructure.bodyOpening + "
" +
+ details + "
";
+ if (notificationType != "deleted")
+ body += emailStructure.bodyHintToLink + url + "/emm/EventRegistration/EventRegistration/?ref_id=" + ref_id + "
";
+ body += emailStructure.bodyClosing + "
" +
emailStructure.bodyClosingName;
var es = new EmailService();
diff --git a/Controllers/EventRegistrationResultController.cs b/Controllers/EventRegistrationResultController.cs
index e8cdfa8..c540dac 100644
--- a/Controllers/EventRegistrationResultController.cs
+++ b/Controllers/EventRegistrationResultController.cs
@@ -187,7 +187,7 @@ private void SendNotification(XmlDocument data, Event e)
string subject = emailStructure.removeFromWaitingListSubject + e.Name;
string body = emailStructure.bodyTitle + first_name + " " + last_name + ", " + "
" +
- emailStructure.removeFromWaitingList1 + e.Name + emailStructure.removeFromWaitingList2 + "
" +
+ emailStructure.removeFromWaitingList1 + "
" +
emailStructure.bodyClosing + "
" +
emailStructure.bodyClosingName;
diff --git a/Helper/EmailHelper.cs b/Helper/EmailHelper.cs
index 1217306..ebca672 100644
--- a/Helper/EmailHelper.cs
+++ b/Helper/EmailHelper.cs
@@ -38,7 +38,8 @@ public class EmailStructure
public string bodyClosingName { get; set; }
public string removeFromWaitingListSubject { get; set; }
public string removeFromWaitingList1 { get; set; }
- public string removeFromWaitingList2 { get; set; }
+ public string deletedSubject { get; set; }
+ public string deletedMessage { get; set; }
public EmailStructure()