示例#1
0
        public async Task <IViewComponentResult> InvokeAsync(long blogId, bool IsEditable)
        {
            var results = new List <DetailedSectionVm>();

            var blog     = blogService.GetBlogWithId(blogId);
            var sectsIds = blogService.SectionsOfBlog(blogId);


            foreach (var sectId in sectsIds)
            {
                var s     = sectionsService.GetSectionWithId(sectId);
                var posts = sectionsService.TopNPosts(sectId, 5);

                var result = new DetailedSectionVm()
                {
                    Name            = s.Name,
                    Id              = s.Id,
                    PhotoId         = s.PhotoId,
                    IsSystemCreated = s.IsSystemCreated,
                    Posts           = posts,
                    BlogId          = blogId,
                    OwnerId         = blog.UserId,
                    OwnerUsername   = userInfoService.GetUserWithId(blog.UserId).Username
                };

                results.Add(result);
            }

            if (IsEditable)
            {
                return(View("Editable", new MainScreenSectionRow()
                {
                    DetailedSections = results
                }));
            }
            else
            {
                return(View("Default", new MainScreenSectionRow()
                {
                    DetailedSections = results
                }));
            }
        }
示例#2
0
        public async Task <IViewComponentResult> InvokeAsync(long blogId)
        {
            var sectionRow = new List <SmallSectionVm>();
            var sectionIds = blogService.SectionsOfBlog(blogId);

            foreach (var sectId in sectionIds)
            {
                var sect = sectionsService.GetSectionWithId(sectId);
                sectionRow.Add(new SmallSectionVm()
                {
                    Id      = sectId,
                    Title   = sect.Name,
                    PhotoId = sect.PhotoId,
                    BlogId  = blogId,
                    Posts   = await FillPosts(sectId)
                });
            }

            return(View("SectionRow", sectionRow));
        }
示例#3
0
        public IActionResult SectionDetails(long sectId)
        {
            var section = sectionsService.GetSectionWithId(sectId);

            if (section is null)
            {
                return(NotFound("The Section you are looking for has been deleted or is unaccessible"));
            }

            var posts = sectionsService.AllPosts(sectId).ToList();
            var blogs = sectionsService.BlogsUsingSectId(sectId);

            return(View("SectionDetails", new DetailedSectionVm()
            {
                Id = sectId,
                BlogId = (section.IsSystemCreated)? -1 : blogs.FirstOrDefault().Id,
                // daca nu este systemCreated, tin minte la ce blog apartine cand afisez sectiunea
                OwnerId = (section.IsSystemCreated) ? -1 : blogs.FirstOrDefault().UserId,
                Name = section.Name,
                Posts = posts,
                PhotoId = section.PhotoId,
                IsSystemCreated = section.IsSystemCreated
            }));
        }