public void HasGetSet()
 {
     var value = new InstitutionalAgreement();
     var entity = new InstitutionalAgreementFile { Agreement = value };
     entity.ShouldNotBeNull();
     entity.Agreement.ShouldEqual(value);
 }
예제 #2
0
            public void HasGetSet()
            {
                var value  = new InstitutionalAgreement();
                var entity = new InstitutionalAgreementFile {
                    Agreement = value
                };

                entity.ShouldNotBeNull();
                entity.Agreement.ShouldEqual(value);
            }
예제 #3
0
        public void Handle(AttachFileToAgreementCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var agreement = command.Agreement ??
                            _entities.Get <InstitutionalAgreement>()
                            .EagerLoad(_entities, new Expression <Func <InstitutionalAgreement, object> >[]
            {
                r => r.Files,
            })
                            .By(command.AgreementGuid);

            var file = agreement.Files.SingleOrDefault(g => g.EntityId == command.FileGuid);

            if (file != null)
            {
                return;
            }

            var looseFile = _entities.Get <LooseFile>().By(command.FileGuid);

            if (looseFile == null)
            {
                return;
            }

            // also store in binary data
            var path = string.Format(InstitutionalAgreementFile.PathFormat, agreement.RevisionId, Guid.NewGuid());

            _binaryData.Put(path, looseFile.Content);

            file = new InstitutionalAgreementFile
            {
                Agreement = agreement,
                //Content = looseFile.Content,
                Length   = looseFile.Length,
                MimeType = looseFile.MimeType,
                Name     = looseFile.Name,
                Path     = path,
            };

            _entities.Create(file);
            _entities.Purge(looseFile);
            command.IsNewlyAttached = true;
        }