Beispiel #1
0
        public IActionResult PostFormCarousel(CarouselModel carouselModel)
        {
            var lastImages = imageManager.Get().Reverse().Take(2).ToList();

            try
            {
                Carousel entity = carouselManager.Get().Where(e => e.Id == carouselModel.num).FirstOrDefault();
                entity.Image_Id = lastImages[1].Id;
                entity.Title    = carouselModel.title;
                entity.Text     = carouselModel.text;
                entity.ImageMin = lastImages[0].ImagePath;
                carouselManager.Update(entity);
            }
            catch (Exception ex)
            {
                Carousel carousel = new Carousel()
                {
                    Image_Id = lastImages[1].Id,
                    Text     = carouselModel.text
                };
                carouselManager.Insert(carousel);
            }

            return(RedirectToAction("Carousel"));
        }
Beispiel #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
            }));
        }
Beispiel #3
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
            }));
        }