Skip to content

Commit f5207b7

Browse files
Closing handling #33
1 parent 6c08519 commit f5207b7

8 files changed

Lines changed: 46 additions & 16 deletions

File tree

Controllers/EventController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
141141

142142
if (model.Id == 0)
143143
{
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);
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.Closed, model.LogInPassword, model.EmailBCC, model.EmailCC, model.EmailReply, ms, null);
145145

146146
newEvent = SaveFile(file, newEvent, eManager);
147147
eManager.UpdateEvent(newEvent);
@@ -179,7 +179,10 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
179179
e.StartDate = model.StartDate;
180180
e.Deadline = model.Deadline;
181181
e.ParticipantsLimitation = model.ParticipantsLimitation;
182+
e.WaitingList = model.WaitingList;
183+
e.WaitingListLimitation = model.WaitingListLimitation;
182184
e.EditAllowed = model.EditAllowed;
185+
e.Closed = model.Closed;
183186
e.LogInPassword = model.LogInPassword;
184187
e.LogInPassword = model.LogInPassword;
185188
e.EmailCC = model.EmailCC;
@@ -191,7 +194,7 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
191194
eManager.UpdateEvent(e);
192195
}
193196

194-
return View("EventManager");
197+
return RedirectToAction("EventManager");
195198
}
196199
}
197200
else

Controllers/EventRegistrationController.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ private List<EventRegistrationModel> GetAvailableEvents(string ref_id = null)
8989
model.NumberOfRegistration = erManager.GetAllRegistrationsNotDeletedByEvent(e.Id).Count;
9090
model.NrOfRegistrationWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count;
9191

92-
if((model.NrOfRegistrationWaitingList >= e.WaitingListLimitation) && (model.NrOfRegistrationWaitingList>= e.ParticipantsLimitation) )
93-
{
94-
model.Closed = true;
95-
}
92+
model.Closed = e.Closed;
9693

9794
//check if user already registered (if logged in)
9895
if (user != null)
@@ -583,7 +580,6 @@ public ActionResult Save()
583580
else
584581
CreateNewEventRegistration(e, data, user, email, notificationType, ref_id);
585582

586-
587583
return Json(new { result = "redirect", url = Url.Action("EventRegistration", "EventRegistration", new { area = "EMM", ref_id = ref_id }) }, JsonRequestBehavior.AllowGet);
588584
}
589585
}
@@ -597,16 +593,34 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
597593
{
598594
bool waitingList = false;
599595
using (var erManager = new EventRegistrationManager())
596+
using(var eventManager = new EventManager())
600597
{
601-
602598
//check Participants Limitation
603599
if (e.ParticipantsLimitation != 0)
604600
{
605601
int countRegs = erManager.GetNumerOfRegistrationsByEvent(e.Id);
602+
int countWaitingList = erManager.GetAllWaitingListRegsByEvent(e.Id).Count + 1;
603+
606604
if (countRegs >= e.ParticipantsLimitation)
607605
{
608-
notificationType = "succesfully_registered_waiting_list";
609-
waitingList = true;
606+
if(e.WaitingList && !e.Closed)
607+
{
608+
if(countWaitingList == e.WaitingListLimitation)
609+
{
610+
e.Closed = true;
611+
eventManager.UpdateEvent(e);
612+
}
613+
614+
notificationType = "succesfully_registered_waiting_list";
615+
waitingList = true;
616+
617+
}
618+
else
619+
{
620+
e.Closed = true;
621+
eventManager.UpdateEvent(e);
622+
notificationType = "succesfully_registered";
623+
}
610624
}
611625
else
612626
{
@@ -618,10 +632,10 @@ private void CreateNewEventRegistration(Event e, XDocument data, User user, stri
618632
notificationType = "succesfully_registered";
619633
}
620634

621-
// Save registration and send notification
622-
erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
635+
// Save registration and send notification
636+
erManager.CreateEventRegistration(XmlMetadataWriter.ToXmlDocument(data), e, user, false, ref_id, waitingList);
623637

624-
SendEmailNotification(notificationType, email, ref_id, data, e, user);
638+
SendEmailNotification(notificationType, email, ref_id, data, e, user);
625639
}
626640
}
627641

Controllers/EventRegistrationResultController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ public ActionResult MoveFromWaitingList(long id, long eventId)
167167

168168
}
169169

170-
171-
172170
return RedirectToAction("OnSelectTreeViewItem", new { id = eventId });
173171
}
174172

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class Event : BusinessEntity
3535

3636
public virtual bool EditAllowed { get; set; }
3737

38+
public virtual bool Closed { get; set; }
39+
3840
public virtual string LogInPassword { get; set; }
3941

4042
public virtual string EmailBCC { get; set; }

Models/EventModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class EventModel
5050
[DisplayName("Allow edit")]
5151
public bool EditAllowed { get; set; }
5252

53+
public bool Closed { get; set; }
5354
public bool EditMode { get; set; }
5455

5556
[DisplayName("Event password")]
@@ -103,6 +104,9 @@ public EventModel(Event eEvent)
103104
StartDate = eEvent.StartDate;
104105
Deadline = eEvent.Deadline;
105106
ParticipantsLimitation = eEvent.ParticipantsLimitation;
107+
WaitingList = eEvent.WaitingList;
108+
WaitingListLimitation = eEvent.WaitingListLimitation;
109+
Closed = eEvent.Closed;
106110

107111
//if (eEvent.ParticipantsLimitation == 0)
108112
// ParticipantsLimitation = "no limitation";

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
<property name="EditAllowed" type="Boolean">
9696
<column name="EditAllowed" />
9797
</property>
98+
99+
<property name="Closed" type="Boolean">
100+
<column name="Closed" />
101+
</property>
98102

99103
<property name="LogInPassword" type="string">
100104
<column name="LogInPassword" />

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

Lines changed: 2 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 waitingList, int waitingListLimitation, 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, bool closed, string logInPassword, string emailBCC, string emailCC, string emailReply, MetadataStructure metadataStructure, string javaScriptPath)
7676
{
7777
E.Event newEvent = new E.Event();
7878
newEvent.Name = name;
@@ -87,6 +87,7 @@ public E.Event CreateEvent(string name, string eventDate, string importantInform
8787
newEvent.WaitingList = waitingList;
8888
newEvent.WaitingListLimitation = waitingListLimitation;
8989
newEvent.EditAllowed = editAllowed;
90+
newEvent.Closed = closed;
9091
newEvent.LogInPassword = logInPassword;
9192
newEvent.EmailBCC = emailBCC;
9293
newEvent.EmailCC = emailCC;

Views/Event/EditEvent.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@
194194
<small>@Html.ValidationMessage("EmailReply")</small>
195195
</td>
196196
</tr>
197+
<tr>
198+
<td>@Html.LabelFor(m => m.Closed)</td>
199+
<td>@Html.CheckBoxFor(m => m.Closed, new { @class = "js-switch" })</td>
200+
</tr>
197201

198202
</table>
199203

0 commit comments

Comments
 (0)