Example #1
0
        public IActionResult AboutUnion(int id)
        {
            var carouselLst        = carouselManager.GetAll().ToList();
            var fbLst              = faceBookManager.GetAll().ToList();
            var projLst            = projectsManager.GetAll().ToList();
            var newsLst            = newsManager.GetAll().ToList();
            var videoLst           = videoManager.GetAll().ToList();
            var imgLst             = imageManager.GetAll().ToList();
            var partnersManagerLst = partnersManager.GetAll().ToList();
            var aboutUnionLst      = aboutUnionManager.GetAll().ToList();


            return(View(new StartPageViewModel()
            {
                CarouselLst = carouselLst,
                FaceBookLst = fbLst,
                ProjectsLst = projLst,
                VideoLst = videoLst,
                NewsLst = newsLst,
                ImagesLst = imgLst,
                PartnersLst = partnersManagerLst,
                AboutUnionLst = aboutUnionLst,
                id = id
            }));
        }
Example #2
0
        public IActionResult Index()
        {
            if (!imageManager.GetAll().Any())
            {
                imageManager.Insert(new Image()
                {
                    ImagePath = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg"
                });
                imageManager.Insert(new Image()
                {
                    ImagePath = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg"
                });
            }
            if (!carouselManager.GetAll().Any())
            {
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
            }
            while (projectsManager.GetAll().Count() < 3)
            {
                projectsManager.Insert(new Projects()
                {
                    Image_Id = 1, Title = "Default text"
                });
            }

            if (!faceBookManager.GetAll().Any())
            {
                faceBookManager.Insert(new FaceBook()
                {
                    FBPost = "Default text", Date = DateTime.Now, Image_Id = 1, PersonLink = "#", PersonName = "Default Name"
                });
            }
            while (videoManager.GetAll().Count() < 4)
            {
                videoManager.Insert(new Video()
                {
                    Text      = "Default Text",
                    VideoFile = "<iframe width=\"854\" height=\"480\" src=\"https://www.youtube.com/embed/TFHcJMzgYiE\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>",
                    Day       = DateTime.Today.Day,
                    Month     = ((MonthEnum)DateTime.Today.Month - 1).ToString(),
                    Year      = DateTime.Today.Year
                });
            }


            List <FaceBook> fbLst;

            if (faceBookManager.GetAll().Count() > 5)
            {
                fbLst = faceBookManager.Get().Reverse().Take(5).ToList();
            }
            else
            {
                fbLst = faceBookManager.GetAll().ToList();
            }

            var carouselLst = carouselManager.GetAll().ToList();

            News[] news = newsManager.GetAll().ToArray();


            for (int i = 0; i < newsManager.GetAll().Count(); i++)//construction to sort dates
            {
                for (int i2 = i + 1; i2 < newsManager.GetAll().Count(); i2++)
                {
                    DateTime date1 = new DateTime();
                    DateTime date2 = new DateTime();
                    News     temp  = null;
                    foreach (MonthEnum item in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i].Month == item.ToString())
                        {
                            date1 = new DateTime(news[i].Year, (int)item + 1, news[i].Day);
                            break;
                        }
                    }

                    foreach (MonthEnum item2 in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i2].Month == item2.ToString())
                        {
                            date2 = new DateTime(news[i2].Year, (int)item2 + 1, news[i2].Day);
                            break;
                        }
                    }

                    if (DateTime.Compare(date1, date2) < 0)
                    {
                        temp     = news[i];
                        news[i]  = news[i2];
                        news[i2] = temp;
                    }
                    else
                    {
                        break;
                    }
                }
            }


            List <News> newsLst;

            if (newsManager.GetAll().Count() > 8)
            {
                newsLst = news.Take(8).ToList();
            }
            else
            {
                newsLst = news.ToList();
            }

            var          projLst     = projectsManager.GetAll().ToList();
            var          partnersLst = partnersManager.GetAll().ToList();
            var          videoLst    = videoManager.GetAll().ToList();
            var          imgLst      = imageManager.GetAll().ToList();
            var          mediaLst    = mediaManager.GetAll().ToList();
            AbstractInfo info        = null;

            if (abstractInfoManager.GetAll().Count() < 1)
            {
                info = new AbstractInfo()
                {
                    Title = "по умолчанию", Text = "09826259810"
                };
            }
            else
            {
                info = abstractInfoManager.Get().LastOrDefault();
            }

            return(View(new StartPageViewModel()
            {
                CarouselLst = carouselLst,
                FaceBookLst = fbLst,
                ProjectsLst = projLst,
                VideoLst = videoLst,
                NewsLst = newsLst,
                ImagesLst = imgLst,
                PartnersLst = partnersLst,
                MediaLst = mediaLst,
                Info = info
            }));
        }
Example #3
0
        public IActionResult Index(int page = 1)
        {
            if (!videoManager.GetAll().Any())
            {
                videoManager.Insert(new Video()
                {
                    Text = "Default Text", VideoFile = "<iframe width=\"854\" height=\"480\" src=\"https://www.youtube.com/embed/TFHcJMzgYiE\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>"
                });
            }
            var carouselLst = carouselManager.GetAll().ToList();
            var fbLst       = faceBookManager.GetAll().ToList();
            var newsLst     = newsManager.GetAll().ToList();
            var projLst     = projectsManager.GetAll().ToList();
            var imgLst      = imageManager.GetAll().ToList();

            ///////////////////////////////////////////////
            Video[] videoLst = videoManager.GetAll().ToArray();


            for (int i = 0; i < videoManager.GetAll().Count(); i++)//construction to sort dates
            {
                for (int i2 = i + 1; i2 < videoManager.GetAll().Count(); i2++)
                {
                    DateTime date1 = new DateTime();
                    DateTime date2 = new DateTime();
                    Video    temp  = null;
                    foreach (MonthEnum item in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (videoLst[i].Month == item.ToString())
                        {
                            date1 = new DateTime(videoLst[i].Year, (int)item + 1, videoLst[i].Day);
                            break;
                        }
                    }

                    foreach (MonthEnum item2 in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (videoLst[i2].Month == item2.ToString())
                        {
                            date2 = new DateTime(videoLst[i2].Year, (int)item2 + 1, videoLst[i2].Day);
                            break;
                        }
                    }

                    if (DateTime.Compare(date1, date2) < 0)
                    {
                        temp         = videoLst[i];
                        videoLst[i]  = videoLst[i2];
                        videoLst[i2] = temp;
                    }
                    else
                    {
                        break;
                    }
                }
            }


            int pageSize = 3;   // количество элементов на странице

            //var videos = videoManager.GetAll().Reverse().ToList();
            var count = videoLst.Count();
            var items = videoLst.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel  VideosPageViewModel = new PageViewModel(count, page, pageSize);
            IndexViewModel viewModel           = new IndexViewModel
            {
                VideosPageInfo = VideosPageViewModel,
                Videos         = items
            };

            return(View(new StartPageViewModel()
            {
                CarouselLst = carouselLst,
                FaceBookLst = fbLst,
                ProjectsLst = projLst,
                VideoLst = videoLst.ToList(),
                NewsLst = newsLst,
                ImagesLst = imgLst,
                IndexViewModel = viewModel
            }));
        }
Example #4
0
        public IActionResult News(int page = 1)
        {
            if (!imageManager.GetAll().Any())
            {
                imageManager.Insert(new Image()
                {
                    ImagePath = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg"
                });
            }
            if (!carouselManager.GetAll().Any())
            {
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
            }
            while (projectsManager.GetAll().Count() < 4)
            {
                projectsManager.Insert(new Projects()
                {
                    Image_Id = 1, Title = "Default text"
                });
            }
            if (!faceBookManager.GetAll().Any())
            {
                faceBookManager.Insert(new FaceBook()
                {
                    FBPost = "Default text", Date = DateTime.Now, PersonLink = "#", PersonName = "Default Name"
                });
            }
            while (videoManager.GetAll().Count() < 4)
            {
                videoManager.Insert(new Video()
                {
                    Text = "Default Text", VideoFile = "<iframe width=\"854\" height=\"480\" src=\"https://www.youtube.com/embed/TFHcJMzgYiE\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>"
                });
            }

            List <FaceBook> fbLst;

            if (faceBookManager.GetAll().Count() > 5)
            {
                fbLst = faceBookManager.Get().Reverse().Take(5).ToList();
            }
            else
            {
                fbLst = faceBookManager.GetAll().ToList();
            }

            var carouselLst = carouselManager.GetAll().ToList();
            var projLst     = projectsManager.GetAll().ToList();
            var videoLst    = videoManager.GetAll().ToList();
            var imgLst      = imageManager.GetAll().ToList();
            var partnersLst = partnersManager.GetAll().ToList();
            int pageSize    = 4;

            News [] news = newsManager.GetAll().ToArray();


            for (int i = 0; i < newsManager.GetAll().Count(); i++)//construction to sort dates
            {
                for (int i2 = i + 1; i2 < newsManager.GetAll().Count(); i2++)
                {
                    DateTime date1 = new DateTime();
                    DateTime date2 = new DateTime();
                    News     temp  = null;
                    foreach (MonthEnum item in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i].Month == item.ToString())
                        {
                            date1 = new DateTime(news[i].Year, (int)item + 1, news[i].Day);
                            break;
                        }
                    }

                    foreach (MonthEnum item2 in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i2].Month == item2.ToString())
                        {
                            date2 = new DateTime(news[i2].Year, (int)item2 + 1, news[i2].Day);
                            break;
                        }
                    }

                    if (DateTime.Compare(date1, date2) < 0)
                    {
                        temp     = news[i];
                        news[i]  = news[i2];
                        news[i2] = temp;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            var count = news.Count();
            var items = news.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel  NewsPageViewModel = new PageViewModel(count, page, pageSize);
            IndexViewModel viewModel         = new IndexViewModel
            {
                NewsPageInfo = NewsPageViewModel,
                News         = items
            };

            return(View(new StartPageViewModel()
            {
                CarouselLst = carouselLst,
                FaceBookLst = fbLst,
                ProjectsLst = projLst,
                VideoLst = videoLst,
                NewsLst = news.ToList(),
                ImagesLst = imgLst,
                PartnersLst = partnersLst,
                IndexViewModel = viewModel
            }));
        }