Skip to content

Commit 614089c

Browse files
waiting list feature #33
1 parent f01e6c6 commit 614089c

12 files changed

Lines changed: 93 additions & 9 deletions

File tree

Controllers/EventController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
118118

119119
if (model.ImportantInformation == null)
120120
ModelState.AddModelError("ImportantInformation", "Important information is required.");
121+
122+
if(model.ParticipantsLimitation == 0 && model.WaitingList == true)
123+
ModelState.AddModelError("WaitingList", "You don't need a waiting list if there is no participants limitation.");
124+
125+
if (model.WaitingListLimitation > 0 && model.WaitingList == false)
126+
ModelState.AddModelError("WaitingListLimitation", "You don't need a waiting list limitation if you dont use the waiting list.");
127+
121128

122129
//check if schema file is uploaded
123130
//if (attachments ==null &&model.Id == 0)
@@ -134,7 +141,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
134141

135142
if (model.Id == 0)
136143
{
137-
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);
144+
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);
138145

139146
newEvent = SaveFile(file, newEvent, eManager);
140147
eManager.UpdateEvent(newEvent);

Controllers/EventRegistrationController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,18 @@ public ActionResult Save()
587587
/// <returns></returns>
588588
private void CreateNewEventRegistration(Event e, XDocument data, User user, string email, string notificationType, string ref_id)
589589
{
590+
bool waitingList = false;
590591
using (var erManager = new EventRegistrationManager())
591592
{
593+
592594
//check Participants Limitation
593595
if (e.ParticipantsLimitation != 0)
594596
{
595597
int countRegs = erManager.GetNumerOfRegistrationsByEvent(e.Id);
596598
if (countRegs >= e.ParticipantsLimitation)
597599
{
598600
notificationType = "succesfully_registered_waiting_list";
601+
waitingList = true;
599602
}
600603
else
601604
{
@@ -608,7 +611,7 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
608611
}
609612

610613
// Save registration and send notification
611-
erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id);
614+
erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
612615

613616
SendEmailNotification(notificationType, email, ref_id, data, e, user);
614617
}

Controllers/EventRegistrationResultController.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public ActionResult OnSelectTreeViewItem(long id)
131131
{
132132
EventRegistrationResultModel model = new EventRegistrationResultModel();
133133
model.Results = GetEventResults(id);
134+
134135
model.EventId = id;
135136

136137
//check rights on event
@@ -177,6 +178,32 @@ private DataTable GetEventResults(long eventId)
177178
return results;
178179
}
179180

181+
private DataTable GetWaitingListResults(long eventId)
182+
{
183+
DataTable results = new DataTable();
184+
results.Columns.Add("Deleted");
185+
186+
using (EventRegistrationManager erManager = new EventRegistrationManager())
187+
{
188+
List<EventRegistration> eventRegistrations = erManager.GetAllWaitingListRegsByEvent(eventId);
189+
190+
if (eventRegistrations.Count != 0)
191+
{
192+
XmlNodeReader xmlNodeReader = new XmlNodeReader(eventRegistrations[0].Data);
193+
results = CreateDataTableColums(results, XElement.Load(xmlNodeReader));
194+
xmlNodeReader.Dispose();
195+
}
196+
197+
foreach (EventRegistration er in eventRegistrations)
198+
{
199+
XmlNodeReader xmlNodeReader = new XmlNodeReader(er.Data);
200+
results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results, er.Deleted.ToString()));
201+
xmlNodeReader.Dispose();
202+
}
203+
}
204+
205+
return results;
206+
}
180207
//private DataTable GetEventRegistration(long eventId, XDocument data)
181208
//{
182209
// DataTable results = new DataTable();

Entities/BExIS.Emm.Entities/Events/Event.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public class Event : BusinessEntity
2929

3030
public virtual int ParticipantsLimitation { get; set; }
3131

32+
public virtual bool WaitingList { get; set; }
33+
34+
public virtual int WaitingListLimitation { get; set; }
35+
3236
public virtual bool EditAllowed { get; set; }
3337

3438
public virtual string LogInPassword { get; set; }

Entities/BExIS.Emm.Entities/Events/EventRegistration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class EventRegistration : BusinessEntity
1919

2020
public virtual string Token { get; set; }
2121

22+
public virtual bool WaitingList { get; set; }
23+
24+
2225
#endregion
2326

2427
#region Associations

Models/EventModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public class EventModel
4141
[DisplayName("Participants limitation")]
4242
public int ParticipantsLimitation { get; set; }
4343

44+
[DisplayName("Allow waiting list")]
45+
public bool WaitingList { get; set; }
46+
47+
[DisplayName("Waiting list limitation")]
48+
public int WaitingListLimitation { get; set; }
49+
4450
[DisplayName("Allow edit")]
4551
public bool EditAllowed { get; set; }
4652

Models/EventRegistrationModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace BExIS.Modules.EMM.UI.Models
1212
{
1313

1414
/// <summary>
15-
/// The EventRegistrationModel represent all informatio ehich are needed to handel a event registration.
15+
/// The EventRegistrationModel represent all information which are needed to handel a event registration.
1616
/// </summary>
1717
/// <remarks></remarks>
1818
public class EventRegistrationModel
@@ -100,6 +100,7 @@ public class EventRegistrationResultModel
100100
public long EventId { get; set; }
101101
public XmlDocument Form { get; set; }
102102
public DataTable Results { get; set; }
103+
public DataTable WaitingListResults { get; set; }
103104
public bool UserHasRights { get; set; }
104105

105106
public EventRegistrationResultModel()

Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/Event.hbm.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@
8383
<property name="ParticipantsLimitation" type="Int32">
8484
<column name="ParticipantsLimitation" />
8585
</property>
86+
87+
<property name="WaitingList" type="Boolean">
88+
<column name="WaitingList" />
89+
</property>
90+
91+
<property name="WaitingListLimitation" type="Int32">
92+
<column name="WaitingListLimitation" />
93+
</property>
8694

8795
<property name="EditAllowed" type="Boolean">
8896
<column name="EditAllowed" />

Orm/BExIS.Emm.Orm.NH/Mappings/Default/Event/EventRegistration.hbm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<property name="Token" type="String">
3232
<column name="Token" />
3333
</property>
34+
35+
<property name="WaitingList" type="Boolean">
36+
<column name="WaitingList" />
37+
</property>
3438

3539
<!-- Mapping Entity Associations -->
3640

Services/BExIS.Emm.Services/Event/EventManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public E.Event GetEventById(long id)
7272
/// <summary>
7373
/// Creates an EventRegistration <seealso cref="EventRegistration"/> and persists the entity in the database.
7474
/// </summary>
75-
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)
75+
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)
7676
{
7777
E.Event newEvent = new E.Event();
7878
newEvent.Name = name;
@@ -84,6 +84,8 @@ public E.Event CreateEvent(string name, string eventDate, string importantInform
8484
newEvent.StartDate = startDate;
8585
newEvent.Deadline = deadline;
8686
newEvent.ParticipantsLimitation = participantsLimitation;
87+
newEvent.WaitingList = waitingList;
88+
newEvent.WaitingListLimitation = waitingListLimitation;
8789
newEvent.EditAllowed = editAllowed;
8890
newEvent.LogInPassword = logInPassword;
8991
newEvent.EmailBCC = emailBCC;

0 commit comments

Comments
 (0)