Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            btnAddToFav.Src = "Images/star.png";

            var churchId = 0;

            if (Request["id"] == null && Page.RouteData.Values["church-id"] == null)
            {
                return;
            }

            if (Request["id"] != null)
            {
                churchId = Convert.ToInt32(Request["id"]);
            }
            else if (Page.RouteData.Values["church-id"] != null)
            {
                churchId = Convert.ToInt32(Page.RouteData.Values["church-id"]);
            }

            var service = new ChurchService();

            var favoriteService = new FavoritesService();

            var timeStandard = new TimeStandard();

            var churches = service.Find(churchId);

            simbahanID.Value           = churchId.ToString();
            churchName.InnerHtml       = churches.Parish;
            churchAddress.InnerHtml    = churches.CompleteAddress;
            churchLastUpdate.InnerHtml = churches.LastUpdate.ToString("MMM d, yyyy");
            churchHistory.InnerHtml    = HttpUtility.HtmlDecode(churches.ChurchHistory) == ""
                ? "<h3>No Data Available.</h3>"
                : "<strong>" + churches.Parish + "</strong> " + HttpUtility.HtmlDecode(churches.ChurchHistory);
            churchType.InnerHtml        = ChurchType.parseInt(churches.ChurchTypeID);
            churchEstablished.InnerHtml = churches.DateEstablished;
            churchFeastDay.InnerHtml    = churches.FeastDay;
            churchPriest.InnerHtml      = churches.Priest;
            churchVicariate.InnerHtml   = churches.Vicariate;
            churchDiocese.InnerHtml     = churches.Diocese;
            churchContact.InnerHtml     = churches.ContactNo;
            churchWebsite.InnerHtml     = "Website: " + churches.Website;
            adorationSchedule.InnerHtml = churches.AdorationDisplayText;
            churchMapAddress.InnerHtml  = churches.CompleteAddress;
            churchMapDestination.Value  = churches.CompleteAddress;

            baptismSchedule.InnerHtml  = churches.BaptismDetails;
            weddingSchedule.InnerHtml  = churches.WeddingDetails;
            officeHours.InnerHtml      = churches.OfficeHours;
            devotionSchedule.InnerHtml = churches.DevotionSchedule;
            latitude.Value             = churches.Latitude.ToString();
            longitude.Value            = churches.Longitude.ToString();

            editChurchHistory.InnerHtml = churches.ChurchHistory;

            if (Auth.Check())
            {
                if (favoriteService.IsChurchAlreadyInFavorites(Auth.user().Id, churches.SimbahanID))
                {
                    AddFav.Attributes.Add("style", "display: none;");
                    RemoveFav.Attributes.Add("style", "display: block;");
                }
                else
                {
                    AddFav.Attributes.Add("style", "display: block;");
                    RemoveFav.Attributes.Add("style", "display: none;");
                }
            }
            else
            {
                RemoveFav.Attributes.Add("style", "display: none");
            }

            List <MassDetailsModel> schedules;


            switch (DateTime.Now.DayOfWeek)
            {
            case DayOfWeek.Sunday:
                schedules = churches.SundayMassSchedule;
                break;

            case DayOfWeek.Monday:
                schedules = churches.MondayMassSchedule;
                break;

            case DayOfWeek.Tuesday:
                schedules = churches.TuesdayMassSchedule;
                break;

            case DayOfWeek.Wednesday:
                schedules = churches.WednesdayMassSchedule;
                break;

            case DayOfWeek.Thursday:
                schedules = churches.ThursdayMassSchedule;
                break;

            case DayOfWeek.Friday:
                schedules = churches.FridayMassSchedule;
                break;

            case DayOfWeek.Saturday:
                schedules = churches.SaturdayMassSchedule;
                break;

            default:
                schedules = new List <MassDetailsModel>();
                break;
            }

            var languages     = new List <string>();
            var massSchedules = new List <string>();

            foreach (var mass in schedules)
            {
                if (mass.Language != "" && !languages.Contains(mass.Language))
                {
                    languages.Add(mass.Language);
                }

                massSchedules.Add(mass.Time);
            }

            var massDate = "No Mass Schedule for " + DateTime.Now.DayOfWeek;

            churchMassLanguages.Attributes.Add("style", "display: none;");
            if (massSchedules.Count > 0)
            {
                massDate = DateTime.Now.DayOfWeek + " - " + string.Join(", ", massSchedules);
                churchMassLanguages.Attributes.Add("style", "display: block;");
            }

            churchMassDates.InnerHtml     = massDate;
            churchMassLanguages.InnerHtml = string.Join(", ", languages);

            adorationChapelSchedule.InnerHtml = churches.AdorationDisplayText;

            confessionSchedule.InnerHtml = churches.ConfessionDetails.Count > 0
                ? churches.ConfessionDetails[0].Text
                : "";

            if (!string.IsNullOrEmpty(churches.LocationType))
            {
                var locationLabel = new CheckLabel(churches.LocationType);
                churchLocation.InnerHtml = locationLabel.ToHtml();
            }

            foreach (var ventilation in churches.Ventilations)
            {
                var ventilationLabel = new CheckLabel(ventilation.VentType);

                churchVentilations.InnerHtml += ventilationLabel.ToHtml();
            }

            foreach (var ventilation in churches.AdorationVentilations)
            {
                var ventilationLabel = new CheckLabel(ventilation);

                adorationVentilations.InnerHtml += ventilationLabel.ToHtml();
            }

            foreach (var parking in churches.ChurchParking)
            {
                var parkingLabel = new CheckLabel(parking.ParkingType);

                churchParking.InnerHtml += parkingLabel.ToHtml();
            }

            for (var i = 5; i <= 22; i++)
            {
                var row = new HtmlTableRow();

                var dayTime       = new HtmlTableCell();
                var sundayMass    = new HtmlTableCell();
                var mondayMass    = new HtmlTableCell();
                var tuesdayMass   = new HtmlTableCell();
                var wednesdayMass = new HtmlTableCell();
                var thursdayMass  = new HtmlTableCell();
                var fridayMass    = new HtmlTableCell();
                var saturdayMass  = new HtmlTableCell();

                var sundayTime    = churches.SundayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var mondayTime    = churches.MondayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var tuesdayTime   = churches.TuesdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var wednesdayTime =
                    churches.WednesdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var thursdayTime =
                    churches.ThursdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var fridayTime   = churches.FridayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);
                var saturdayTime =
                    churches.SaturdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i);

                dayTime.InnerHtml = timeStandard.Time[i - 1];

                sundayMass.InnerHtml =
                    sundayTime != null ? sundayTime.Time + "<br/>" + sundayTime.Language : "";

                mondayMass.InnerHtml =
                    mondayTime != null ? mondayTime.Time + "<br/>" + mondayTime.Language : "";

                tuesdayMass.InnerHtml =
                    tuesdayTime != null ? tuesdayTime.Time + "<br/>" + tuesdayTime.Language : "";

                wednesdayMass.InnerHtml =
                    wednesdayTime != null ? wednesdayTime.Time + "<br/>" + wednesdayTime.Language : "";

                thursdayMass.InnerHtml =
                    thursdayTime != null ? thursdayTime.Time + "<br/>" + thursdayTime.Language : "";

                fridayMass.InnerHtml =
                    fridayTime != null ? fridayTime.Time + "<br/>" + fridayTime.Language : "";

                saturdayMass.InnerHtml =
                    saturdayTime != null ? saturdayTime.Time + "<br/>" + saturdayTime.Language : "";

                row.Cells.Add(dayTime);
                row.Cells.Add(sundayMass);
                row.Cells.Add(mondayMass);
                row.Cells.Add(tuesdayMass);
                row.Cells.Add(wednesdayMass);
                row.Cells.Add(thursdayMass);
                row.Cells.Add(fridayMass);
                row.Cells.Add(saturdayMass);
                row.Attributes.Add("class", "text-center");

                massScheduleTable.Rows.Add(row);
            }

            if (churches.Announcements.Count > 0)
            {
                foreach (var announcement in churches.Announcements)
                {
                    var announcementControl = new Components.Announcement(announcement);

                    churchAnnouncementContainer.InnerHtml += announcementControl.ToHtml();
                }
            }
            else
            {
                churchAnnouncementContainer.InnerHtml += "<h4>No Announcement Found.</h4>";
            }

            foreach (var review in churches.ChurchReviews)
            {
                var reviewItem = new Components.ChurchReview(review);

                churchReviewsContainer.InnerHtml += reviewItem.ToHtml();
            }

            var slider = new ImageSlider();

            if (churches.ChurchPhotos.Count > 0)
            {
                slider.FirstImage = churches.ChurchPhotos[0].ChurchPhotos;

                for (var i = 0; i < churches.ChurchPhotos.Count; i++)
                {
                    slider.AddImage(i, churches.ChurchPhotos[i].ChurchPhotos);
                }

                cssSlider.InnerHtml = slider.ToHtml();
            }
            else
            {
                cssSlider.InnerHtml = "<h3 class=\"text-center\">No Photos Available.</h3>";
            }

            if (churches.AdorationPhotos.Count > 0)
            {
                for (var i = 0; i < churches.AdorationPhotos.Count; i++)
                {
                    var imagePath = ResolveUrl(churches.AdorationPhotos[i]);

                    var newLi = new HtmlGenericControl("li")
                    {
                        InnerHtml = "<img src=\"" + imagePath +
                                    "\" alt=\"\" title=\"\" id=\"wows1_" + i + "\" />"
                    };
                    adorationImageList.Controls.Add(newLi);

                    var newA = new HtmlGenericControl("a");
                    newA.Attributes.Add("href", "#");
                    newA.InnerHtml = "<a href=\"#\" title=\"\"><span><img src=\"" + imagePath +
                                     "\" alt=\"\" />" + (i + 1) + "</span></a>";
                    adorationLinkList.Controls.Add(newA);
                }
            }
            else
            {
                adorationImageContainer.InnerHtml = "<h3>No Photos Available</h3>";
            }

            Master.GoogleMetaDescription = massDate;
            Page.Title = churches.Parish;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var organizationId = 0;
            if (Request["id"] == null && Page.RouteData.Values["organization-id"] == null)
                return;

            if (Request["id"] != null)
                organizationId = Convert.ToInt32(Request["id"]);
            else if (Page.RouteData.Values["organization-id"] != null)
                organizationId = Convert.ToInt32(Page.RouteData.Values["organization-id"]);

            var organizationService = new OrganizationService();

            var organization = organizationService.Find(organizationId);
            var todayMass = organization.Masses
                .Where(mass => mass.ScheduleId == (int) DateTime.Now.DayOfWeek + 1)
                .ToList();

            OrganizationId.Value = organization.Id.ToString();
            OrganizationName.InnerHtml = organization.Name;
            OrganizationAbout.InnerHtml = organization.About;
            OrganizationAddress.InnerHtml = organization.Address;
            OrgAddress.InnerHtml = organization.Address;
            var worshipScheduleString = todayMass.Count < 0 ? "No Worship Schedule Available for This Day"
                : DateTime.Now.DayOfWeek + " " + string.Join(", ", todayMass.Select(mass => mass.Time));
            WorshipScheduleToday.InnerHtml = worshipScheduleString;
            ParentOrganization.InnerHtml = organization.ParentOrganization;
            LastUpdated.InnerHtml = organization.LastUpdate.ToString("MMMM dd, yyyy");
            Location.InnerHtml = organization.Branch;
            InfoOrganizationName.InnerHtml = organization.Name;
            InfoParentOrganization.InnerHtml = organization.ParentOrganization;
            DateEstablished.InnerHtml = organization.DateEstablished;
            ContactNumber.InnerHtml = organization.ContactNumber;
            Email.InnerHtml = organization.Email;
            Website.InnerHtml = organization.Website;
            latitude.Value = organization.Latitude.ToString();
            longitude.Value = organization.Longitude.ToString();
            organizationMapDestination.Value = organization.Address;

            RetreatSchedule.InnerHtml = organization.RetreatSchedule;
            RecollectionSchedule.InnerHtml = organization.RecollectionSchedule;
            TalkSchedule.InnerHtml = organization.TalkSchedule;
            CampSchedule.InnerHtml = organization.CampSchedule;
            VolunteerSchedule.InnerHtml = organization.VolunteerSchedule;


            foreach (var activity in organization.Activities)
                Activities.InnerHtml += new CheckLabel(activity).ToHtml();

            foreach (var attendee in organization.Attendees)
                Attendees.InnerHtml += new CheckLabel(attendee).ToHtml();

            foreach (var location in organization.Locations)
                Venues.InnerHtml += new CheckLabel(location).ToHtml();

            foreach (var ventilation in organization.Ventilations)
                Ventilations.InnerHtml += new CheckLabel(ventilation).ToHtml();

            foreach (var parking in organization.Parkings)
                Parkings.InnerHtml += new CheckLabel(parking).ToHtml();

            foreach (var mass in organization.Masses)
                MassSchedule.Controls.Add(new HtmlGenericControl("li") {InnerHtml = mass.Time});

            foreach (var bibleSchedule in organization.BibleStudySchedules)
                BibleSchedule.Controls.Add(new HtmlGenericControl("li") {InnerHtml = bibleSchedule.Time});

            foreach (var worshipSchedule in organization.WorshipSchedules)
                WorshipSchedule.Controls.Add(new HtmlGenericControl("li") {InnerHtml = worshipSchedule.Time});

            var slider = new ImageSlider();

            if (organization.Photos.Count > 0)
            {
                slider.FirstImage = organization.Photos[0];

                for (var i = 0; i < organization.Photos.Count; i++)
                    slider.AddImage(i, organization.Photos[i]);

                cssSlider.InnerHtml = slider.ToHtml();
            }
            else
            {
                cssSlider.InnerHtml = "<h3 class=\"text-center\">No Photos Available.</h3>";
            }

            var reviews = new OrganizationReviewService().Get(organization.Id);

            foreach (var review in reviews)
            {
                var reviewItem = new Components.OrganizationReview(review);

                organizationReviewsContainer.InnerHtml += reviewItem.ToHtml();
            }

            Page.Title = organization.Name;

            if (Auth.Check())
            {
                var favoriteService = new FavoritesService();
                if (favoriteService.IsOrganizationAlreadyInFavorites(Auth.user().Id, organization.Id))
                {
                    AddFav.Attributes.Add("style", "display: none;");
                    RemoveFav.Attributes.Add("style", "display: block;");
                }
                else
                {
                    AddFav.Attributes.Add("style", "display: block;");
                    RemoveFav.Attributes.Add("style", "display: none;");
                }
            }
            else
            {
                RemoveFav.Attributes.Add("style", "display: none");
            }

            var announcementService = new OrganizationAnnouncementService();
            var announcements = announcementService.Get(organization.Id);

            foreach (Models.OrganizationAnnouncement announcement in announcements)
            {
                var component = new Components.OrganizationAnnouncement(announcement);

                announcementContainer.InnerHtml += component.ToHtml();
            }
        }