コード例 #1
0
        public bool BlockSection(SectionDetailsViewModel blockModel)
        {
            var section = _sectionService.GetSectionEntity(blockModel.Id);

            if (section == null)
            {
                return(false);
            }
            section.IsBlocked = blockModel.IsBlocked;
            _sectionService.UpdateSection(section);
            return(true);
        }
コード例 #2
0
        public SectionDetailsViewModel SectionDetails(int id)
        {
            var section = this.DbContext.Sections
                          .Include(s => s.Publications)
                          .ThenInclude(s => s.Author)
                          .FirstOrDefault(s => s.Id == id);

            if (section == null)
            {
                return(null);
            }

            SectionDetailsViewModel model = this.Mapper.Map <SectionDetailsViewModel>(section);

            return(model);
        }
コード例 #3
0
        public static SectionDetailsViewModel ToSectionDetailsModel(this SectionEntity entity)
        {
            var viewModel = new SectionDetailsViewModel()
            {
                CreationDate         = entity.CreationDate,
                IsBlocked            = entity.IsBlocked,
                Id                   = entity.Id,
                SectionName          = entity.SectionName,
                UserRefId            = entity.UserRefId,
                SettedModeratorLogin = entity.ModeratorLogin,
            };

            foreach (var category in entity.Categories)
            {
                viewModel.Categories.Add(category.CategoryName);
            }
            return(viewModel);
        }