예제 #1
0
        public void TestDetachAccess()
        {
            var employer0 = CreateEmployer(0);
            var employer1 = CreateEmployer(1);

            // Save attachments.

            const int count       = 3;
            var       attachments = new MemberMessageAttachment[count];

            for (var index = 0; index < count; ++index)
            {
                attachments[index] = CreateMessageAttachment(employer0, index);
            }

            // Check attachments.

            AssertAttachments(employer0, attachments);

            _employerMemberContactsCommand.DeleteMessageAttachment(employer1, attachments[2].Id);
            AssertAttachments(employer0, attachments);
            AssertAttachments(employer1);

            _employerMemberContactsCommand.DeleteMessageAttachment(employer1, attachments[0].Id);
            AssertAttachments(employer0, attachments);
            AssertAttachments(employer1);

            _employerMemberContactsCommand.DeleteMessageAttachment(employer1, attachments[1].Id);
            AssertAttachments(employer0, attachments);
            AssertAttachments(employer1);
        }
예제 #2
0
        public void TestDetach()
        {
            var employer = CreateEmployer(0);

            // Save attachments.

            const int count       = 3;
            var       attachments = new MemberMessageAttachment[count];

            for (var index = 0; index < count; ++index)
            {
                attachments[index] = CreateMessageAttachment(employer, index);
            }

            // Check attachments.

            AssertAttachments(employer, attachments);

            _employerMemberContactsCommand.DeleteMessageAttachment(employer, attachments[2].Id);
            AssertAttachments(employer, attachments.Take(2).ToArray());

            _employerMemberContactsCommand.DeleteMessageAttachment(employer, attachments[0].Id);
            AssertAttachments(employer, attachments[1]);

            _employerMemberContactsCommand.DeleteMessageAttachment(employer, attachments[1].Id);
            AssertAttachments(employer);
        }
예제 #3
0
 void IEmployerContactsRepository.CreateMessageAttachment(Guid employerId, MemberMessageAttachment attachment)
 {
     using (var dc = CreateContext())
     {
         dc.EmployerMemberAttachmentEntities.InsertOnSubmit(attachment.Map(employerId));
         dc.SubmitChanges();
     }
 }
예제 #4
0
        private void AssertAttachment(JsonFileModel model, MemberMessageAttachment attachment)
        {
            Assert.AreEqual(model.Id, attachment.Id);
            var fileReference = _filesQuery.GetFileReference(attachment.FileReferenceId);

            Assert.IsNotNull(fileReference);
            Assert.AreEqual(model.Name, fileReference.FileName);
            Assert.AreEqual(model.Size, fileReference.FileData.ContentLength);
        }
예제 #5
0
파일: Mappings.cs 프로젝트: formist/LinkMe
 public static EmployerMemberAttachmentEntity Map(this MemberMessageAttachment attachment, Guid employerId)
 {
     return(new EmployerMemberAttachmentEntity
     {
         id = attachment.Id,
         uploadedTime = attachment.UploadedTime,
         employerId = employerId,
         fileReferenceId = attachment.FileReferenceId,
     });
 }
예제 #6
0
        public void TestMultipleContactsMultipleAttachments()
        {
            var employer = CreateEmployer(0);

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer.Id
            });

            const int count   = 3;
            var       members = new Member[count];

            for (var index = 0; index < count; ++index)
            {
                members[index] = CreateMember(index);
            }

            // Save attachments.

            var attachments = new MemberMessageAttachment[count];

            for (var index = 0; index < count; ++index)
            {
                attachments[index] = CreateMessageAttachment(employer, index);
            }

            // Check attachments.

            AssertAttachments(employer, attachments);

            // Create messages.

            var templateMessage = new ContactMemberMessage {
                Subject = Subject, Body = Body, AttachmentIds = (from a in attachments select a.Id).ToList()
            };

            _employerMemberContactsCommand.ContactMembers(_app, employer, _employerMemberViewsQuery.GetProfessionalViews(employer, members), templateMessage);

            // Check.

            for (var index = 0; index < count; ++index)
            {
                var messages = _employerMemberContactsQuery.GetMessages(employer, members[index].Id);
                Assert.AreEqual(1, messages.Count);
                AssertMessage(templateMessage, messages[0], null, _employerContactsRepository.GetMemberMessageRepresentative(messages[0].Id));
            }
        }
예제 #7
0
        public void TestMultipleAttachments()
        {
            var employer = CreateEmployer(0);

            // Save attachments.

            const int count       = 3;
            var       attachments = new MemberMessageAttachment[count];

            for (var index = 0; index < count; ++index)
            {
                attachments[index] = CreateMessageAttachment(employer, index);
            }

            // Check attachments.

            AssertAttachments(employer, attachments);
        }
        MemberMessageAttachment IEmployerMemberContactsCommand.CreateMessageAttachment(IEmployer employer, IEnumerable <Guid> existingAttachmentIds, FileContents fileContents, string fileName)
        {
            // Check first.

            Validate(employer.Id, existingAttachmentIds, fileContents, fileName);

            // Save the file.

            var fileReference = _filesCommand.SaveFile(FileType.Attachment, fileContents, fileName);

            // Create the attachment to be saved.

            var attachment = new MemberMessageAttachment {
                FileReferenceId = fileReference.Id
            };

            attachment.Prepare();
            attachment.Validate();
            _repository.CreateMessageAttachment(employer.Id, attachment);

            return(attachment);
        }
예제 #9
0
 private static void AssertAttachment(MemberMessageAttachment expectedAttachment, MemberMessageAttachment attachment)
 {
     Assert.AreEqual(expectedAttachment.Id, attachment.Id);
     Assert.AreEqual(expectedAttachment.FileReferenceId, attachment.FileReferenceId);
 }