Exemple #1
0
 public BlogListWidgetModel()
 {
     Blogs    = new List <BlogWidgetModel>();
     Users    = new List <UserModel>();
     Subjects = new Dictionary <string, int>();
     PagingFilteringContext = new PagingFilteringModel();
 }
        /// <summary>
        /// Indexes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        public ActionResult Index(BookSearchModel model, PagingFilteringModel command)
        {
            PrepareBookModel(model);

            var request = new BookRequest()
            {
                Name        = model.Name,
                Begin       = model.Begin,
                DegreeId    = model.DegreeId,
                End         = model.End,
                GradeId     = model.GradeId,
                Isbn        = model.Isbn,
                PublisherId = model.PublisherId,
                SubjectId   = model.SubjectId,
                TermId      = model.TermId,
                Year        = model.Year,
                PageIndex   = command.PageIndex,
                PageSize    = 10
            };
            var pageData = _bookService.GetBookPage(request);

            model.BookList = pageData;
            model.PagingFilteringModel.LoadPagedList(pageData);
            return(View(model));
        }
Exemple #3
0
 public NewsListWidgetModel()
 {
     News    = new List <NewsWidgetModel>();
     Authors = new Dictionary <string, int>();
     PagingFilteringContext = new PagingFilteringModel();
     AvailableStatuses      = new List <SelectListItem>();
 }
Exemple #4
0
 public EventListWidgetModel()
 {
     Events    = new List <EventWidgetModel>();
     Pictures  = new List <PictureModel>();
     Videos    = new List <VideoModel>();
     Locations = new Dictionary <string, int>();
     PagingFilteringContext = new PagingFilteringModel();
 }
 public BookTaskModel()
 {
     PagingFilteringModel = new PagingFilteringModel();
 }
 public ProductListWidgetModel()
 {
     Products               = new List <ProductModel>();
     ProductCategories      = new List <ProductCategoryModel>();
     PagingFilteringContext = new PagingFilteringModel();
 }
 public BookSearchModel()
 {
     PagingFilteringModel = new PagingFilteringModel();
 }
Exemple #8
0
        public ActionResult List(PagingFilteringModel command, FormCollection frm)
        {
            var model = new NewsListWidgetModel();
            var itemsPerPageSetting = _settingService.GetSettingByKey("ItemsPerPage");

            if (command.PageSize <= 0)
            {
                command.PageSize = itemsPerPageSetting != null?Convert.ToInt32(itemsPerPageSetting.Value) : 25;
            }
            if (command.PageNumber <= 0)
            {
                command.PageNumber = 1;
            }

            var news = _newsService.GetPagedNews(keyword: command.Keyword, author: command.Author, statusid: command.NewsStatusId, pageIndex: command.PageNumber - 1, pageSize: command.PageSize, onlyActive: true);

            model.PagingFilteringContext.LoadPagedList(news);
            model.PagingFilteringContext.Keyword      = command.Keyword;
            model.PagingFilteringContext.Author       = command.Author;
            model.PagingFilteringContext.NewsStatusId = command.NewsStatusId;

            foreach (var record in news)
            {
                var objNews = record.ToWidgetModel();
                objNews.CreatedOn  = record.CreatedOn;
                objNews.ModifiedOn = record.ModifiedOn;

                var newsPictures = _pictureService.GetNewsPictureByNewsId(record.Id).OrderByDescending(x => x.StartDate).ToList();
                objNews.HasDefaultPicture = newsPictures.Any(x => x.IsDefault);

                var newsVideos = _videoService.GetNewsVideosByNewsId(record.Id).OrderByDescending(x => x.StartDate).ToList();
                objNews.HasDefaultVideo = newsVideos.Count > 0;

                if (newsPictures.Count > 0)
                {
                    objNews.DefaultPictureSrc = newsPictures.FirstOrDefault(x => objNews.HasDefaultPicture ? x.IsDefault : true).Picture.PictureSrc;
                    objNews.Pictures          = newsPictures.Select(x => x.ToModel()).ToList();
                }

                if (newsVideos.Count > 0)
                {
                    objNews.DefaultVideoSrc = newsVideos.FirstOrDefault().Video.VideoSrc;
                    objNews.Videos          = newsVideos.Select(x => x.ToModel()).ToList();
                }

                objNews.Reactions = _smsService.SearchReactions(newsid: record.Id).Select(x => x.ToModel()).OrderByDescending(x => x.CreatedOn).ToList();
                objNews.Comments  = _commentService.GetCommentsByNews(record.Id).OrderByDescending(x => x.CreatedOn).Select(x => x.ToWidgetModel()).ToList();

                if (objNews.Comments.Count > 0)
                {
                    foreach (var comment in objNews.Comments)
                    {
                        comment.Replies = _replyService.GetAllRepliesByComment(comment.Id).OrderBy(x => x.DisplayOrder).Select(x => x.ToWidgetModel()).ToList();
                    }
                }

                objNews.LatestPosts = _newsService.GetLatestNews(objNews.Id).Select(x => x.ToWidgetModel()).OrderByDescending(x => x.CreatedOn).Take(3).ToList();
                foreach (var post in objNews.LatestPosts)
                {
                    var postPictures = _pictureService.GetNewsPictureByNewsId(post.Id).OrderByDescending(x => x.StartDate).ToList();
                    post.HasDefaultPicture = postPictures.Any(x => x.IsDefault);

                    var postVideos = _videoService.GetNewsVideosByNewsId(post.Id).OrderByDescending(x => x.StartDate).ToList();
                    post.HasDefaultVideo = postVideos.Count > 0;

                    if (postPictures.Count > 0)
                    {
                        post.DefaultPictureSrc = postPictures.FirstOrDefault(x => post.HasDefaultPicture ? x.IsDefault : true).Picture.PictureSrc;
                        post.Pictures          = postPictures.Select(x => x.ToModel()).ToList();
                    }

                    if (postVideos.Count > 0)
                    {
                        post.DefaultVideoSrc = postVideos.FirstOrDefault().Video.VideoSrc;
                        post.Videos          = postVideos.Select(x => x.ToModel()).ToList();
                    }
                }

                objNews.OlderPosts = _newsService.GetOlderNews(objNews.Id).Select(x => x.ToWidgetModel()).OrderByDescending(x => x.CreatedOn).Take(3).ToList();
                foreach (var post in objNews.OlderPosts)
                {
                    var postPictures = _pictureService.GetNewsPictureByNewsId(post.Id).OrderByDescending(x => x.StartDate).ToList();
                    post.HasDefaultPicture = postPictures.Any(x => x.IsDefault);

                    var postVideos = _videoService.GetNewsVideosByNewsId(post.Id).OrderByDescending(x => x.StartDate).ToList();
                    post.HasDefaultVideo = postVideos.Count > 0;

                    if (postPictures.Count > 0)
                    {
                        post.DefaultPictureSrc = postPictures.FirstOrDefault(x => post.HasDefaultPicture ? x.IsDefault : true).Picture.PictureSrc;
                        post.Pictures          = postPictures.Select(x => x.ToModel()).ToList();
                    }

                    if (postVideos.Count > 0)
                    {
                        post.DefaultVideoSrc = postVideos.FirstOrDefault().Video.VideoSrc;
                        post.Videos          = postVideos.Select(x => x.ToModel()).ToList();
                    }
                }

                model.News.Add(objNews);
            }

            model.Authors           = _newsService.GetDistinctAuthorAndCount(true);
            model.AvailableStatuses = (from NewsStatus d in Enum.GetValues(typeof(NewsStatus))
                                       select new SelectListItem
            {
                Text = EnumExtensions.GetDescriptionByValue <NewsStatus>(Convert.ToInt32(d)),
                Value = Convert.ToInt32(d).ToString(),
                Selected = (model.PagingFilteringContext.NewsStatusId == Convert.ToInt32(d))
            }).ToList();
            return(View(model));
        }