예제 #1
0
 void Instance_PublishingContent(object sender, EPiServer.ContentEventArgs e)
 {
     if (e.Content as ParticipantBlock != null)
     {
         ParticipantBlock participant = (e.Content as ParticipantBlock);
         ParticipantLog.AddLogText("Saved", "Participant saved with e-mail " + participant.Email + " and status " + participant.AttendStatus, participant);
     }
 }
예제 #2
0
        public override ActionResult Index(MyPageBlock currentBlock)
        {
            var model = new MyPageBlockViewModel <MyPageBlock>(currentBlock);

            string email       = Request.QueryString["email"];
            string code        = Request.QueryString["code"];
            string cancelEvent = Request.QueryString["cancelEvent"];
            string editEvent   = Request.QueryString["editEvent"];

            if (email.IsNullOrEmpty() || code.IsNullOrEmpty())
            {
                return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/EmptyView.cshtml", model));  //No results found, code not matching email.
            }
            var currentParticipant = BVNetwork.Attend.Business.API.AttendRegistrationEngine.GetParticipant(email, code);

            if (currentParticipant == null)
            {
                return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/EmptyView.cshtml", model));
            }


            ////Set name
            if (currentParticipant != null)
            {
                model.ParticipantName = currentParticipant.Username;
            }


            //Cancel event?
            if (cancelEvent == "true" && currentParticipant != null)
            {
                var entry = (currentParticipant as BlockData).CreateWritableClone() as ParticipantBlock;
                if (entry.AttendStatus != AttendStatus.Cancelled.ToString())
                {
                    entry.AttendStatus = AttendStatus.Cancelled.ToString();
                    ParticipantLog.AddLogText("Status change", "Status changed to ", entry);
                    _contentRepository.Save(entry as IContent, SaveAction.Publish, AccessLevel.NoAccess);
                    AttendRegistrationEngine.SendStatusMail(entry);
                    return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/Cancelled.cshtml", model));
                }
            }

            model.RegistrationCode = code;
            model.Email            = email;
            model.CurrentBlock     = currentBlock;

            //Edit event?
            if (editEvent == "true" && currentParticipant != null)
            {
                model.CurrentEvent     = _contentRepository.Get <EventPageBase>(currentParticipant.EventPage);
                model.PredefinedValues = currentParticipant.XForm;
                return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/EditEvent.cshtml", model));  //Edit event
            }


            var entries = BVNetwork.Attend.Business.API.AttendRegistrationEngine.GetParticipantByEmail(email);

            model.AllEntries      = new List <ParticipantBlock>();
            model.UpcomingEntries = new List <ParticipantBlock>();
            model.PastEntries     = new List <ParticipantBlock>();

            foreach (var entry in entries)
            {
                if (entry.EventPage == null || entry.EventPage == PageReference.EmptyReference)
                {
                    continue;
                }
                model.AllEntries.Add(entry as ParticipantBlock);

                var eventPage = BVNetwork.Attend.Business.API.AttendRegistrationEngine.GetEventPageBase(entry);
                if ((eventPage).EventDetails.EventEnd > DateTime.Now) //&& (entry.AttendStatus.Contains(AttendStatus.Confirmed.ToString()) || entry.AttendStatus == AttendStatus.Submitted.ToString() || entry.AttendStatus == AttendStatus.Standby.ToString()))
                {
                    model.UpcomingEntries.Add(entry as ParticipantBlock);
                }
                else
                {
                    model.PastEntries.Add(entry as ParticipantBlock);
                }
            }
            model.UpcomingEntries = model.UpcomingEntries.OrderBy(x => x.EventPageData().EventDetails.EventEnd).ToList();

            if (model.UpcomingEntries.Count == 0)
            {
                return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/EmptyView.cshtml", model));  //No results found, code not matching email.
            }

            var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <IPageRouteHelper>();

            model.CurrentPage = pageRouteHelper.Page;

            return(View("~/Modules/BVNetwork.Attend/Views/Blocks/MyPageBlock/Index.cshtml", model));  //No results found, code not matching email.
        }