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); }
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); }
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); }