@@ -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
0 commit comments