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); }
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); }
void IEmployerContactsRepository.CreateMessageAttachment(Guid employerId, MemberMessageAttachment attachment) { using (var dc = CreateContext()) { dc.EmployerMemberAttachmentEntities.InsertOnSubmit(attachment.Map(employerId)); dc.SubmitChanges(); } }
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); }
public static EmployerMemberAttachmentEntity Map(this MemberMessageAttachment attachment, Guid employerId) { return(new EmployerMemberAttachmentEntity { id = attachment.Id, uploadedTime = attachment.UploadedTime, employerId = employerId, fileReferenceId = attachment.FileReferenceId, }); }
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)); } }
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); }
private static void AssertAttachment(MemberMessageAttachment expectedAttachment, MemberMessageAttachment attachment) { Assert.AreEqual(expectedAttachment.Id, attachment.Id); Assert.AreEqual(expectedAttachment.FileReferenceId, attachment.FileReferenceId); }