Ejemplo n.º 1
0
        public IActionResult Contacts()
        {
            AbstractInfo info = null;

            if (abstractInfoManager.GetAll().Count() < 1)
            {
                info = new AbstractInfo()
                {
                    Title = "по умолчанию", Text = "09826259810"
                };
            }
            else
            {
                info = abstractInfoManager.Get().LastOrDefault();
            }
            return(View(new StartPageViewModel()
            {
                Info = info
            }));
        }
Ejemplo n.º 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
            }));
        }