コード例 #1
0
        public void Add(IEnumerable<CreateDocumentRequest> createDocumentRequests, Guid userId, long companyId)
        {
            _log.Add(createDocumentRequests);

            try
            {
                foreach (var createDocumentRequest in createDocumentRequests)
                {
                    var parameters = new CreateAddedDocumentParameters()
                                         {
                                             ClientId = companyId,
                                             Site = _siteRepository.GetById(createDocumentRequest.SiteId),
                                             CreatedBy = _userForAuditingRepository.GetByIdAndCompanyId(userId, companyId),
                                             CreatedOn = DateTime.Now,
                                             Description = createDocumentRequest.Description,
                                             DocumentLibraryId = createDocumentRequest.DocumentLibraryId,
                                             DocumentType = _documentTypeRepository.GetById((long)createDocumentRequest.DocumentType),
                                             Extension = createDocumentRequest.Extension,
                                             Filename = createDocumentRequest.Filename,
                                             FilesizeByte = createDocumentRequest.FilesizeByte,
                                             Title = createDocumentRequest.Title
                                         };
                    var addedDocument = AddedDocument.Create(parameters);

                    _documentRepository.SaveOrUpdate(addedDocument);
                }
            }
            catch (Exception ex)
            {
                _log.Add(ex);

                throw;
            }
        }
コード例 #2
0
ファイル: Create.cs プロジェクト: mnasif786/Business-Safe
        public void When_requesting_Create_values_are_set_correctly()
        {
            //Given
            var user = new UserForAuditing();

            var createParams = new CreateAddedDocumentParameters()
            {
                ClientId = 1234,
                Title = "wibbly bibbly",
                Description = "Woo hoo",
                DocumentLibraryId = 1,
                DocumentType = new DocumentType(),
                Extension = ".biz",
                Filename = "FooBar",
                FilesizeByte = 2000,
                CreatedBy = user,
                CreatedOn = _now,
                Site = new SiteGroup()
            };


            //When
            var result = AddedDocument.Create(createParams);

            //Then
            Assert.That(result.ClientId, Is.EqualTo(createParams.ClientId));
            Assert.That(result.Title, Is.EqualTo(createParams.Title));
            Assert.That(result.Description, Is.EqualTo(createParams.Description));
            Assert.That(result.DocumentLibraryId, Is.EqualTo(createParams.DocumentLibraryId));
            Assert.That(result.DocumentType, Is.EqualTo(createParams.DocumentType));
            Assert.That(result.Extension, Is.EqualTo(createParams.Extension));
            Assert.That(result.Filename, Is.EqualTo(createParams.Filename));
            Assert.That(result.FilesizeByte, Is.EqualTo(createParams.FilesizeByte));
            Assert.That(result.CreatedBy, Is.EqualTo(user));
            Assert.That(result.CreatedOn, Is.EqualTo(_now));
            Assert.That(result.Site, Is.EqualTo(createParams.Site));
        }