/// <summary>
        /// create the document with desired information.
        /// </summary>
        /// <param name="cmd"></param>
        protected override void Execute(CreateDocumentAsCopy cmd)
        {
            var documentId = _mapper.Map(cmd.Handle);

            //this is idempotent.
            FindAndModify(
                documentId,
                h => {
                if (!h.HasBeenCreated)
                {
                    h.Initialize(documentId, cmd.Handle);
                }
                h.SetFileName(cmd.HandleInfo.FileName);
                h.SetCustomData(cmd.HandleInfo.CustomData);
                h.Link(cmd.DocumentDescriptorId);
            },
                createIfNotExists: true
                );

            //Update document descriptor.
            var documentDescriptor = Repository.GetById <DocumentDescriptor>(cmd.DocumentDescriptorId);

            documentDescriptor.Attach(cmd.HandleInfo);
            Repository.Save(documentDescriptor, cmd.MessageId, d => { });
        }
        protected override void Execute(LinkDocumentToDocumentDescriptor cmd)
        {
            var handleId = _mapper.Map(cmd.HandleInfo.Handle);

            FindAndModify(
                handleId,
                h =>
            {
                if (!h.HasBeenCreated)
                {
                    h.Initialize(handleId, cmd.HandleInfo.Handle);
                }
                h.SetFileName(cmd.HandleInfo.FileName);
                h.SetCustomData(cmd.HandleInfo.CustomData);
                h.Link(cmd.DocumentDescriptorId);
            },
                true);
        }
        protected override void Execute(DeleteDocument cmd)
        {
            var handleId = _mapper.Map(cmd.Handle);

            FindAndModify(handleId, h => h.Delete());
        }
Beispiel #4
0
        /// <summary>
        /// create the document with desired information.
        /// </summary>
        /// <param name="cmd"></param>
        protected override void Execute(CopyDocument cmd)
        {
            var documentId = _mapper.Map(cmd.Handle);

            FindAndModify(documentId, h => h.CopyDocument(cmd.CopiedHandle));
        }