Exemplo n.º 1
0
        public void SetTags(string taglist, Document document)
        {
            if (document == null) throw new ArgumentNullException("document");

            if (taglist == null)
                taglist = string.Empty;

            var tagNames =
                taglist.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(
                    x => !string.IsNullOrWhiteSpace(x));

            var existingTags = document.Tags.ToList();

            tagNames.ForEach(name =>
            {
                var tag = GetTag(name);
                if (tag == null)
                {
                    tag = new Tag { Name = name };
                    _session.Transact(session => session.Save(tag));
                }
                if (!document.Tags.Contains(tag))
                {
                    document.Tags.Add(tag);
                    tag.Documents.Add(document);
                }
                existingTags.Remove(tag);
            });

            existingTags.ForEach(tag =>
            {
                document.Tags.Remove(tag);
                tag.Documents.Remove(document);
            });
        }
Exemplo n.º 2
0
        public static string GetIconClass(Document document)
        {
            DocumentMetadata documentTypeDefinition =
                DocumentMetadatas.FirstOrDefault(
                    x => document.GetType().Name.Equals(x.TypeName, StringComparison.OrdinalIgnoreCase));

            return documentTypeDefinition != null ? documentTypeDefinition.IconClass : null;
        }
Exemplo n.º 3
0
        public VersionsModel GetVersions(Document document, int page)
        {
            IPagedList<DocumentVersion> versions = _session.QueryOver<DocumentVersion>()
                .Where(version => version.Document.Id == document.Id)
                .OrderBy(version => version.CreatedOn).Desc
                .Paged(page);

            return new VersionsModel(versions, document.Id);
        }
Exemplo n.º 4
0
        public IEnumerable<Tag> GetTags(Document document)
        {
            ISet<Tag> parentCategories = new HashSet<Tag>();

            if (document != null)
            {
                if (document.Parent != null)
                    parentCategories = document.Parent.Tags;
            }

            return parentCategories;
        }
Exemplo n.º 5
0
 public OnDocumentUpdatedEventArgs(Document document, string action = null)
 {
     Document = document;
     Action = action ?? "updated";
 }
Exemplo n.º 6
0
 public PartialViewResult Show(Document document, int page = 1)
 {
     return PartialView(_service.GetVersions(document, page));
 }