public DataSourceResult GetAllContents(DataSourceRequest request)
 {
     return(ContentBiz.Read(content =>
                            content.State != ContentState.Trashed, noTracking: true).Include(c => c.Author)
            .MapTo <ContentInfo1PM>()
            .ToDataSourceResult(request));
 }
 public void ChangeContentsState(IEnumerable <int> ids, ContentState state)
 {
     ContentBiz.Read(content =>
                     ids.Contains(content.Id))
     .ToList()
     .ForEach(content => content.State = state);
     UnitOfWork.SaveChanges();
 }
 public void ChangeContentsState(IEnumerable <int> ids, ContentState state, UserIdentity userIdentity)
 {
     ContentBiz.Read(content =>
                     content.AuthorId == userIdentity.UserId &&
                     ids.Contains(content.Id))
     .ToList()
     .ForEach(content => content.State = state);
     UnitOfWork.SaveChanges();
 }
        public void RemoveContents(IEnumerable <int> ids, UserIdentity userIdentity)
        {
            var contentsToRemove = ContentBiz.Read(a => ids.Contains(a.Id) && a.AuthorId == userIdentity.UserId);
            HashSet <string> pictureNamesToRemove = new HashSet <string>();

            foreach (var content in contentsToRemove)
            {
                ContentBiz.Remove(content);
            }
            UnitOfWork.SaveChanges();
        }
        public void ReadPostForEdit(UserIdentity userIdentity, int contentId, out ContentRegistrationPM contentPresentationModel, out List <string> tags)
        {
            var content = ContentBiz.Read(c =>
                                          c.AuthorId == userIdentity.UserId &&
                                          c.Type == ContentType.BlogPost &&
                                          c.State != ContentState.Blocked &&
                                          c.Id == contentId)
                          .Include(c => c.Tags)
                          .Single(c => c.Id == contentId);

            contentPresentationModel = content.GetContentRegistrationPM();
            tags = new List <string>(content.Tags.Select(tag => tag.Text));
        }