public async Task TestGet_CheckProperties() { var business = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Business.Id, EmailAddressTypeName = EmailAddressType.Business.Value }; context.EmailAddressTypes.Add(business); Action <PagedQueryResults <EmailAddressTypeDTO> > tester = (results) => { Assert.AreEqual(1, results.Total); Assert.AreEqual(1, results.Results.Count); var firstResult = results.Results.First(); Assert.AreEqual(business.EmailAddressTypeId, firstResult.Id); Assert.AreEqual(business.EmailAddressTypeName, firstResult.Name); }; var defaultSorter = new ExpressionSorter <EmailAddressTypeDTO>(x => x.Id, SortDirection.Ascending); var queryOperator = new QueryableOperator <EmailAddressTypeDTO>(0, 10, defaultSorter); var serviceResults = service.Get(queryOperator); var serviceResultsAsync = await service.GetAsync(queryOperator); tester(serviceResults); tester(serviceResultsAsync); }
/// <summary> /// Reads the appointments from the Exchange server. /// </summary> /// <param name="owner">The owner RadScheduler instance.</param> /// <returns></returns> public override IEnumerable <Appointment> GetAppointments(RadScheduler owner) { List <Appointment> appointments = new List <Appointment>(); foreach (Resource resource in owner.Resources) { string sharedCalendarName = this.CalendarNames;// resource.Text; // Identify which folders to search. DistinguishedFolderIdType distinguishedFolderIdType = new DistinguishedFolderIdType(); distinguishedFolderIdType.Id = DistinguishedFolderIdNameType.calendar; EmailAddressType emailAddressType = new EmailAddressType(); emailAddressType.EmailAddress = sharedCalendarName; distinguishedFolderIdType.Mailbox = emailAddressType; List <ItemIdType> itemIds = new List <ItemIdType>(); foreach (CalendarItemType item in FindCalendarItems(new DistinguishedFolderIdType[] { distinguishedFolderIdType })) { if ((item.Start < owner.VisibleRangeEnd && item.End > owner.VisibleRangeStart) || item.CalendarItemType1 == CalendarItemTypeType.RecurringMaster) { itemIds.Add(item.ItemId); } } appointments.AddRange(GetAppointments(owner, sharedCalendarName, itemIds.ToArray())); } return(appointments); }
public List <EmailAddressType> GetAll() { EmailAddressTypeDAC _emailAddressTypeComponent = new EmailAddressTypeDAC(); IDataReader reader = _emailAddressTypeComponent.GetAllEmailAddressType().CreateDataReader(); List <EmailAddressType> _emailAddressTypeList = new List <EmailAddressType>(); while (reader.Read()) { if (_emailAddressTypeList == null) { _emailAddressTypeList = new List <EmailAddressType>(); } EmailAddressType _emailAddressType = new EmailAddressType(); if (reader["EmailAddressTypeId"] != DBNull.Value) { _emailAddressType.EmailAddressTypeId = Convert.ToInt32(reader["EmailAddressTypeId"]); } if (reader["Name"] != DBNull.Value) { _emailAddressType.Name = Convert.ToString(reader["Name"]); } if (reader["ModifiedDate"] != DBNull.Value) { _emailAddressType.ModifiedDate = Convert.ToDateTime(reader["ModifiedDate"]); } _emailAddressType.NewRecord = false; _emailAddressTypeList.Add(_emailAddressType); } reader.Close(); return(_emailAddressTypeList); }
public async Task TestCreate_PersonDoesNotExist() { using (ShimsContext.Create()) { System.Data.Entity.Fakes.ShimDbContext.AllInstances.SetOf1 <Person>((c) => { return(context.People); }); var personId = 1; EmailAddressType emailAddressType = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Home.Id, EmailAddressTypeName = EmailAddressType.Home.Value }; context.SetupActions.Add(() => { context.EmailAddressTypes.Add(emailAddressType); }); var user = new User(1); var email = "*****@*****.**"; var emailAddressTypeId = emailAddressType.EmailAddressTypeId; var isPrimary = true; var newEmail = new NewPersonEmailAddress(user, emailAddressTypeId, email, isPrimary, personId); context.Revert(); var message = String.Format("The email addressable entity with id [{0}] was not found.", personId); Action a = () => service.Create(newEmail); Func <Task> f = () => service.CreateAsync(newEmail); a.ShouldThrow <ModelNotFoundException>().WithMessage(message); f.ShouldThrow <ModelNotFoundException>().WithMessage(message); } }
public EmailAddressType GetByID(int _emailAddressTypeId) { EmailAddressTypeDAC _emailAddressTypeComponent = new EmailAddressTypeDAC(); IDataReader reader = _emailAddressTypeComponent.GetByIDEmailAddressType(_emailAddressTypeId); EmailAddressType _emailAddressType = null; while (reader.Read()) { _emailAddressType = new EmailAddressType(); if (reader["EmailAddressTypeId"] != DBNull.Value) { _emailAddressType.EmailAddressTypeId = Convert.ToInt32(reader["EmailAddressTypeId"]); } if (reader["Name"] != DBNull.Value) { _emailAddressType.Name = Convert.ToString(reader["Name"]); } if (reader["ModifiedDate"] != DBNull.Value) { _emailAddressType.ModifiedDate = Convert.ToDateTime(reader["ModifiedDate"]); } _emailAddressType.NewRecord = false; } reader.Close(); return(_emailAddressType); }
public async Task TestUpdate_EmailAddressDoesNotExist() { var personId = 1; Person person = new Person { PersonId = personId }; EmailAddressType emailAddressType = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Home.Id, EmailAddressTypeName = EmailAddressType.Home.Value }; var updatorId = 2; var yesterday = DateTimeOffset.UtcNow.AddDays(-1.0); var emailAddressId = 1; context.EmailAddressTypes.Add(emailAddressType); context.People.Add(person); var updatedEmailModel = new UpdatedEmailAddress(new User(updatorId), emailAddressId, "*****@*****.**", emailAddressType.EmailAddressTypeId, true); var message = String.Format("The email address with id [{0}] was not found.", emailAddressId); Action a = () => service.Update(updatedEmailModel); Func <Task> f = () => service.UpdateAsync(updatedEmailModel); a.ShouldThrow <ModelNotFoundException>().WithMessage(message); f.ShouldThrow <ModelNotFoundException>().WithMessage(message); }
/// <summary> /// Verify EmailAddressType type. /// </summary> /// <param name="emailAddress">An instance of EmailAddressType type.</param> /// <param name="isSchemaValidated">The result of schema validation, true means valid.</param> private void VerifyEmailAddressType(EmailAddressType emailAddress, bool isSchemaValidated) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1147"); Site.CaptureRequirementIfIsTrue( isSchemaValidated, "MS-OXWSCDATA", 1147, @"[In t:EmailAddessType Complex Type] The type [EmailAddressType] is defined as follow: <xs:complexType name=""EmailAddressType""> <xs:complexContent> <xs:extension base=""t:BaseEmailAddressType"" > <xs:sequence> <xs:element name=""Name"" type=""xs:string"" minOccurs=""0"" /> <xs:element name=""EmailAddress"" type=""t:NonEmptyStringType"" minOccurs=""0"" /> <xs:element name=""RoutingType"" type=""t:NonEmptyStringType"" minOccurs=""0"" /> <xs:element name=""MailboxType"" type=""t:MailboxTypeType"" minOccurs=""0"" /> <xs:element name=""ItemId"" type=""t:ItemIdType"" minOccurs=""0"" /> <xs:element name=""OriginalDisplayName"" type=""xs:string"" minOccurs=""0""/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>"); if (!string.IsNullOrEmpty(emailAddress.EmailAddress)) { this.VerifyNonEmptyStringType(isSchemaValidated); } if (emailAddress.MailboxTypeSpecified) { this.VerifyMailboxTypeType(isSchemaValidated); } if (!string.IsNullOrEmpty(emailAddress.RoutingType)) { this.VerifyNonEmptyStringType(isSchemaValidated); } }
public void AddEmailAddress(EmailAddressType type, string address) { if (_emailAddresses == null) { _emailAddresses = new List <EmailAddress>(1); } _emailAddresses.Add(EmailAddress.Create(type, address)); }
//************************************************************************* // Constructor: EmailAddressFormatException() // /// <summary> /// Initializes a new instance of the <see /// cref="EmailAddressFormatException" /> class. /// </summary> /// /// <param name="emailAddressType"> /// The type of the address that has an invalid format. /// </param> //************************************************************************* public EmailAddressFormatException ( EmailAddressType emailAddressType ) { m_eEmailAddressType = emailAddressType; AssertValid(); }
public void SetUp() { EmailAddressType differentType = EmailAddressType.Work; string address = "*****@*****.**"; emailAddress = new EmailAddress(address); sameEmailAddress = new EmailAddress(address); differentEmailAddress = new EmailAddress(differentType, address); }
public static EmailAddressType ToDomain(this EmailAddressTypeModel model, EmailAddressType domain) { if (model != null) { domain.Id = model.Id; domain.Type = model.Type; } return(domain); }
public bool Insert(EmailAddressType emailaddresstype) { int autonumber = 0; EmailAddressTypeDAC emailaddresstypeComponent = new EmailAddressTypeDAC(); bool endedSuccessfuly = emailaddresstypeComponent.InsertNewEmailAddressType(ref autonumber, emailaddresstype.Name, emailaddresstype.ModifiedDate); if (endedSuccessfuly) { emailaddresstype.EmailAddressTypeId = autonumber; } return(endedSuccessfuly); }
public static EmailAddressTypeModel ToModel(this EmailAddressType domain) { var model = new EmailAddressTypeModel(); if (domain != null) { model.Id = domain.Id; model.Type = domain.Type; } return(model); }
public static EmailAddressType ToDomain(this EmailAddressTypeModel model) { var domain = new EmailAddressType(); if (model != null) { domain.Id = model.Id; domain.Type = model.Type; } return(domain); }
public static EmailAddress Create(EmailAddressType type, string address) { if (string.IsNullOrEmpty(address)) { throw new ArgumentException("Address must be populated"); } return(new EmailAddress() { Type = type.ToFriendlyString(), Address = address }); }
public void AddEmailAddress(string EmailAddress, EmailAddressType Type) { switch (Type) { case EmailAddressType.TO_EMAIL_ADDRESS: _ToEmailAddresses.Add(EmailAddress); break; case EmailAddressType.FROM_EMAIL_ADDRESS: _FromEmailAddresses.Add(EmailAddress); break; case EmailAddressType.CC_EMAIL_ADDRESS: _CCEmailAddresses.Add(EmailAddress); break; default: break; } }
/// <summary> /// /// </summary> /// <param name="emailAddressType"></param> /// <param name="mailingListId"></param> /// <param name="optInType"></param> /// <returns></returns> public int Create(EmailAddressType emailAddressType = null, string mailingListId = null, OptInType optInType = null) { try { if (_create == null) { var req = new CreateEmailAddressReq() { header = Client.RequestHeader }; if (emailAddressType != null) { req.emailAddressType = emailAddressType; } if (!string.IsNullOrWhiteSpace(mailingListId)) { req.mailingListId = int.Parse(mailingListId); } req.mailingListIdSpecified = true; if (optInType != null) { req.optInType = optInType; } _create = _client.API.CreateEmailAddress(req); } if (_create.errorCode == (int)errorCode.No_error) { return(_create.emailAddressId); } throw new FlexMailException(_create.errorMessage, _create.errorCode); } catch (Exception ex) { //telemetry.TrackException(ex, new Dictionary<string, string> { { "Flexmail", "EmailAddress.Create" } }); if (ex is FlexMailException) { throw (ex); } } finally { _create = null; } return(-1); }
public static string ToFriendlyString(this EmailAddressType me) { switch (me) { case EmailAddressType.Home: return("home"); case EmailAddressType.Work: return("work"); default: return(""); } }
/// <summary> /// Creates list of email addresses. /// </summary> /// <param name="emailAddressType">Type of the email address.</param> /// <param name="emailAddresses">Array of email addresses.</param> /// <returns>List<EmailAddress>.</returns> public static EmailAddress[] CreateEmailAddressList(EmailAddressType emailAddressType, params string[] emailAddresses) { Encapsulation.TryValidateParam(emailAddressType, nameof(emailAddressType)); Encapsulation.TryValidateParam(emailAddresses, nameof(emailAddresses)); var addresses = new List <EmailAddress>(); addresses.AddRange(emailAddresses.Select(address => new EmailAddress(address) { EmailAddressType = emailAddressType })); return(addresses.ToArray()); }
private static IEnumerable<EmailAddress> ExtractEmailAddresses(IEnumerable<MailAddress> mailAddresses, EmailAddressType type) { var result = new List<EmailAddress>(); foreach (var recipient in mailAddresses) { result.AddRange(recipient.GetMailboxes().Select(mailbox => new EmailAddress { Name = mailbox.Name, Email = mailbox.Address, Type = type, })); } return result; }
//Email Address String Example: "Kristian Wilson <*****@*****.**>; Julian Inwood <*****@*****.**>" public static IEnumerable<EmailAddress> ToEmailAddressList(this string addressString, EmailAddressType type) { if (addressString.IsNotNullOrEmpty() && addressString.Contains('<') && addressString.Contains('>')) { var addresses = addressString.Split('|'); return addresses.Where(address => address.IsNotNullOrEmpty()) .Select(address => address.Split('<')) .Select(parts => new EmailAddress { Name = parts[0].Trim(), Email = parts[1].TrimEnd('>').Trim(), //get rid of the trailing angle bracket Type = type, }).ToList(); } return new List<EmailAddress>(); }
public async Task TestGetById() { var person = new Person { PersonId = 10, FullName = "full name" }; var emailAddressType = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Home.Id, EmailAddressTypeName = EmailAddressType.Home.Value }; var email = new EmailAddress { Address = "*****@*****.**", PersonId = person.PersonId, Person = person, EmailAddressId = 1, EmailAddressType = emailAddressType, EmailAddressTypeId = emailAddressType.EmailAddressTypeId, IsPrimary = true }; context.EmailAddresses.Add(email); context.EmailAddressTypes.Add(emailAddressType); context.People.Add(person); Action <EmailAddressDTO> tester = (dto) => { Assert.IsNotNull(dto); Assert.AreEqual(email.IsPrimary, dto.IsPrimary); Assert.AreEqual(email.PersonId, dto.PersonId); Assert.AreEqual(email.EmailAddressId, dto.Id); Assert.AreEqual(email.Address, dto.Address); Assert.AreEqual(email.EmailAddressType.EmailAddressTypeName, dto.EmailAddressType); Assert.AreEqual(email.EmailAddressTypeId, dto.EmailAddressTypeId); }; var result = service.GetById(email.EmailAddressId); var resultAsync = await service.GetByIdAsync(email.EmailAddressId); tester(result); tester(resultAsync); }
/// <summary> /// Inserts the specified appointment. /// </summary> /// <param name="owner">The owner RadScheduler instance.</param> /// <param name="appointmentToInsert">The appointment to insert.</param> public override void Insert(RadScheduler owner, Appointment appointmentToInsert) { CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext; if (createExceptionContext != null) { Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception); InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate); return; } CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert); CreateItemType createItemRequest = new CreateItemType(); DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType(); destFolder.Id = DistinguishedFolderIdNameType.calendar; EmailAddressType emailAddressType = new EmailAddressType(); emailAddressType.EmailAddress = this.CalendarNames; destFolder.Mailbox = emailAddressType; createItemRequest.SavedItemFolderId = new TargetFolderIdType(); createItemRequest.SavedItemFolderId.Item = destFolder; createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone; createItemRequest.SendMeetingInvitationsSpecified = true; createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new CalendarItemType[] { calendarItem }; CreateItemResponseType response = Service.CreateItem(createItemRequest); ResponseMessageType responseMessage = response.ResponseMessages.Items[0]; if (responseMessage.ResponseCode != ResponseCodeType.NoError) { throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode); } }
/// <summary> /// Locates the first email address of the specified type while giving preference to email addresses marked as preferred. /// </summary> /// <param name="emailType"> /// The type of email address to locate. This can be any combination of values from <see cref="EmailAddressType" />. /// </param> /// <returns> /// The function returns the first preferred email address that matches the specified type. /// If the collection does not contain a preferred email address, then it will return the first /// non-preferred matching email address. The function returns null if no matches were found. /// </returns> // ReSharper disable once UnusedMember.Global public EmailAddress GetFirstChoice(EmailAddressType emailType) { EmailAddress firstNonPreferred = null; foreach (var email in this) { if ((email.EmailType & emailType) == emailType) { if (firstNonPreferred == null) { firstNonPreferred = email; } if (email.IsPreferred) { return(email); } } } return(firstNonPreferred); }
public async Task TestGetContacts_CheckProperties() { var contact = new Contact { ContactId = 1, FullName = "full name", Position = "position" }; var emailAddressType = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Home.Id, EmailAddressTypeName = EmailAddressType.Home.Value, }; var email = new EmailAddress { Address = "*****@*****.**", Contact = contact, ContactId = contact.ContactId, EmailAddressId = 2, EmailAddressType = emailAddressType, EmailAddressTypeId = emailAddressType.EmailAddressTypeId, IsPrimary = true }; var phoneNumberType = new PhoneNumberType { PhoneNumberTypeId = PhoneNumberType.Cell.Id, PhoneNumberTypeName = PhoneNumberType.Cell.Value }; var phoneNumber = new PhoneNumber { Contact = contact, ContactId = contact.ContactId, Number = "555-5555", Extension = "123", PhoneNumberId = 3, PhoneNumberType = phoneNumberType, PhoneNumberTypeId = phoneNumberType.PhoneNumberTypeId, IsPrimary = true }; context.PhoneNumberTypes.Add(phoneNumberType); context.PhoneNumbers.Add(phoneNumber); context.EmailAddresses.Add(email); context.EmailAddressTypes.Add(emailAddressType); context.Contacts.Add(contact); Action <PagedQueryResults <ContactDTO> > tester = (results) => { Assert.AreEqual(1, results.Total); Assert.AreEqual(1, results.Results.Count); var firstResult = results.Results.First(); Assert.AreEqual(contact.ContactId, firstResult.Id); Assert.AreEqual(contact.FullName, firstResult.FullName); Assert.AreEqual(contact.Position, firstResult.Position); Assert.AreEqual(1, firstResult.EmailAddresses.Count()); var firstEmail = firstResult.EmailAddresses.First(); Assert.AreEqual(email.Address, firstEmail.Address); Assert.AreEqual(email.EmailAddressTypeId, firstEmail.EmailAddressTypeId); Assert.AreEqual(emailAddressType.EmailAddressTypeName, firstEmail.EmailAddressType); Assert.AreEqual(contact.ContactId, firstEmail.ContactId); Assert.IsNull(firstEmail.PersonId); Assert.AreEqual(email.EmailAddressId, firstEmail.Id); Assert.IsTrue(firstEmail.IsPrimary.Value); Assert.AreEqual(1, firstResult.PhoneNumbers.Count()); var firstPhoneNumber = firstResult.PhoneNumbers.First(); Assert.AreEqual(phoneNumberType.PhoneNumberTypeId, firstPhoneNumber.PhoneNumberTypeId); Assert.AreEqual(phoneNumberType.PhoneNumberTypeName, firstPhoneNumber.PhoneNumberType); Assert.AreEqual(phoneNumber.PhoneNumberId, firstPhoneNumber.Id); Assert.AreEqual(phoneNumber.Number, firstPhoneNumber.Number); Assert.AreEqual(phoneNumber.Extension, firstPhoneNumber.Extension); Assert.AreEqual(contact.ContactId, firstPhoneNumber.ContactId); Assert.IsNull(firstPhoneNumber.PersonId); Assert.IsTrue(firstPhoneNumber.IsPrimary.Value); }; var defaultSorter = new ExpressionSorter <ContactDTO>(x => x.Id, SortDirection.Ascending); var queryOperator = new QueryableOperator <ContactDTO>(0, 10, defaultSorter); var serviceResults = service.GetContacts(queryOperator); var serviceResultsAsync = await service.GetContactsAsync(queryOperator); tester(serviceResults); tester(serviceResultsAsync); }
public static IList <IEmailGroup> GetRecipients(this IGroup source, EmailAddressType emailType) { return(source.EmailAddresses.GetRecipients(emailType)); }
/// <summary> /// Creates and populated Exchange message type. /// /// Note: just like SMTP, this function takes the threading parameters, but unlike SMTP it does nothing /// with them. Exchange web services were designed for implementing mail readers, rather than sending mail, /// configuring threading without having access to the mail box is incredibly difficult. Given the limited /// amount of benefit, I gave up. If in the future EWS improves, maybe I will be able to implement this. /// Meanwhile - using SMTP transport is the recommended way. /// </summary> /// <param name="to"> List of 'to' addresses. </param> /// <param name="cc"> List of 'cc' addresses. </param> /// <param name="from"> On-behalf-of account, or null. </param> /// <param name="replyTo"> An alias of the person on behalf of which the mail is sent. </param> /// <param name="subject"> Subject. </param> /// <param name="body"> Body. </param> /// <param name="isBodyHtml"> Whether the body of the message is HTML. </param> /// <param name="threadId"> The id of the thread, if message is a part of the thread. 0 otherwise. /// This is currently unused (see above). </param> /// <param name="isThreadStart"> Whether this is the first message in the thread. This is currently unused /// (see above). </param> /// <returns> Created message structure. </returns> private static MessageType MakeExchangeMessage(List<string> to, List<string> cc, string from, string replyTo, string subject, string body, bool isBodyHtml, int threadId, bool isThreadStart) { MessageType message = new MessageType(); List<EmailAddressType> recipients = new List<EmailAddressType>(); foreach (string email in to) { EmailAddressType address = new EmailAddressType(); address.EmailAddress = email; recipients.Add(address); } message.ToRecipients = recipients.ToArray(); if (cc != null) { recipients = new List<EmailAddressType>(); foreach (string email in cc) { EmailAddressType address = new EmailAddressType(); address.EmailAddress = email; recipients.Add(address); } message.CcRecipients = recipients.ToArray(); } if (@from != null) { message.From = new SingleRecipientType(); message.From.Item = new EmailAddressType(); message.From.Item.EmailAddress = @from; } if (replyTo != null) { EmailAddressType reply = new EmailAddressType(); reply.EmailAddress = replyTo; message.ReplyTo = new EmailAddressType[1]; message.ReplyTo[0] = reply; } message.Subject = subject; message.Sensitivity = SensitivityChoicesType.Normal; message.Body = new BodyType(); message.Body.BodyType1 = isBodyHtml ? BodyTypeType.HTML : BodyTypeType.Text; message.Body.Value = body; return message; }
public EmailAddress(EmailAddressType typeOfEmailAddress, string address) { TypeOfEmailAddress = typeOfEmailAddress; Address = address; }
/// <summary> /// Interactively creates a new email address. /// </summary> /// <returns>The new email address.</returns> public static EmailAddress Create() { string typeOfEmailAddressAsString = MainFunctions.ReadLine("Type: (Personal/work/school/other) ").ToLower(); char firstLetter = 'h'; EmailAddressType typeOfEmailAddress = EmailAddressType.Personal; try { firstLetter = typeOfEmailAddressAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfEmailAddress = EmailAddressType.Work; break; case 's': typeOfEmailAddress = EmailAddressType.School; break; case 'o': typeOfEmailAddress = EmailAddressType.Other; break; default: Console.WriteLine("Keeping default of Personal"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Personal"); } string address = ""; while (true) { string emailAddressString = MainFunctions.ReadLine("Email Address: "); try { MailAddress mailAddress = new MailAddress(emailAddressString); } catch (FormatException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } catch (ArgumentException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } address = emailAddressString; break; } EmailAddress newEmailAddress = new EmailAddress(typeOfEmailAddress, address); return(newEmailAddress); }
public async Task TestGetContactById_CheckProperties() { var contact = new Contact { ContactId = 1, FullName = "full name", Position = "position" }; var emailAddressType = new EmailAddressType { EmailAddressTypeId = EmailAddressType.Home.Id, EmailAddressTypeName = EmailAddressType.Home.Value, }; var email = new EmailAddress { Address = "*****@*****.**", Contact = contact, ContactId = contact.ContactId, EmailAddressId = 2, EmailAddressType = emailAddressType, EmailAddressTypeId = emailAddressType.EmailAddressTypeId, }; var phoneNumberType = new PhoneNumberType { PhoneNumberTypeId = PhoneNumberType.Cell.Id, PhoneNumberTypeName = PhoneNumberType.Cell.Value }; var phoneNumber = new PhoneNumber { Contact = contact, ContactId = contact.ContactId, Number = "555-5555", Extension = "123", PhoneNumberId = 3, PhoneNumberType = phoneNumberType, PhoneNumberTypeId = phoneNumberType.PhoneNumberTypeId }; context.PhoneNumberTypes.Add(phoneNumberType); context.PhoneNumbers.Add(phoneNumber); context.EmailAddresses.Add(email); context.EmailAddressTypes.Add(emailAddressType); context.Contacts.Add(contact); Action <ContactDTO> tester = (serviceResult) => { Assert.IsNotNull(serviceResult); Assert.AreEqual(contact.ContactId, serviceResult.Id); Assert.AreEqual(contact.FullName, serviceResult.FullName); Assert.AreEqual(contact.Position, serviceResult.Position); Assert.AreEqual(1, serviceResult.EmailAddresses.Count()); var firstEmail = serviceResult.EmailAddresses.First(); Assert.AreEqual(email.Address, firstEmail.Address); Assert.AreEqual(email.EmailAddressTypeId, firstEmail.EmailAddressTypeId); Assert.AreEqual(emailAddressType.EmailAddressTypeName, firstEmail.EmailAddressType); Assert.AreEqual(contact.ContactId, firstEmail.ContactId); Assert.IsNull(firstEmail.PersonId); Assert.AreEqual(email.EmailAddressId, firstEmail.Id); Assert.AreEqual(1, serviceResult.PhoneNumbers.Count()); var firstPhoneNumber = serviceResult.PhoneNumbers.First(); Assert.AreEqual(phoneNumberType.PhoneNumberTypeId, firstPhoneNumber.PhoneNumberTypeId); Assert.AreEqual(phoneNumberType.PhoneNumberTypeName, firstPhoneNumber.PhoneNumberType); Assert.AreEqual(phoneNumber.PhoneNumberId, firstPhoneNumber.Id); Assert.AreEqual(phoneNumber.Number, firstPhoneNumber.Number); Assert.AreEqual(phoneNumber.Extension, firstPhoneNumber.Extension); Assert.AreEqual(contact.ContactId, firstPhoneNumber.ContactId); Assert.IsNull(firstPhoneNumber.PersonId); }; var serviceResults = service.GetContactDTOById(contact.ContactId); var serviceResultsAsync = await service.GetContactDTOByIdAsync(contact.ContactId); tester(serviceResults); tester(serviceResultsAsync); }
/// <summary> /// Set MyBase to Value of [dr] /// </summary> /// <param name="pconstring">as data source connection string</param> /// <param name="dr">as data.datarow</param> internal bool SetBase(string pconstring, DataRow dr) { try { if (dr["cntemID"] != System.DBNull.Value) { ID = Convert.ToInt16(dr["cntemID"].ToString()); } if (dr["cntid"] != System.DBNull.Value) { CNTID = new Guid(dr["cntid"].ToString()); } if (dr["cntemType"] != System.DBNull.Value) { Type = (EmailAddressType)Convert.ToInt16(dr["cntemType"].ToString()); } if (dr["cntemEmail"] != System.DBNull.Value) { Email = (String)dr["cntemEmail"]; } if (dr["cntemDisplayAs"] != System.DBNull.Value) { DisplayAs = (String)dr["cntemDisplayAs"]; } return true; } catch (Exception ex) { GetLastError = ex; throw ex; } }
public static IList <IEmailGroup> GetRecipients(this ICollection <IEmailGroup> source, EmailAddressType emailType) { return(source.Where(s => s.EmailTypeID == (int)emailType).ToList <IEmailGroup>()); }
public void MSOXWSFOLD_S08_TC01_AllOperationsWithAllOptionalElements() { #region Configure SOAP header this.ConfigureSOAPHeader(); #endregion #region Create new folders in the inbox folder. // CreateFolder request. CreateFolderType createFolderRequest = this.GetCreateFolderRequest( DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder1", "Custom Folder2", "Custom Folder3", "Custom Folder4" }, new string[] { "IPF.MyCustomFolderClass", "IPF.Appointment", "IPF.Contact", "IPF.Task" }, null); // Set ExtendedProperty defined in BaseFolderType. PathToExtendedFieldType publishInAddressBook = new PathToExtendedFieldType(); // A hexadecimal tag of the extended property. publishInAddressBook.PropertyTag = "0x671E"; publishInAddressBook.PropertyType = MapiPropertyTypeType.Boolean; ExtendedPropertyType pubAddressbook = new ExtendedPropertyType(); pubAddressbook.ExtendedFieldURI = publishInAddressBook; pubAddressbook.Item = "1"; ExtendedPropertyType[] extendedProperties = new ExtendedPropertyType[1]; extendedProperties[0] = pubAddressbook; createFolderRequest.Folders[0].ExtendedProperty = extendedProperties; createFolderRequest.Folders[1].ExtendedProperty = extendedProperties; createFolderRequest.Folders[2].ExtendedProperty = extendedProperties; createFolderRequest.Folders[3].ExtendedProperty = extendedProperties; // Define a permissionSet with all optional elements PermissionSetType permissionSet = new PermissionSetType(); permissionSet.Permissions = new PermissionType[1]; permissionSet.Permissions[0] = new PermissionType(); permissionSet.Permissions[0].ReadItems = new PermissionReadAccessType(); permissionSet.Permissions[0].ReadItems = PermissionReadAccessType.FullDetails; permissionSet.Permissions[0].ReadItemsSpecified = true; permissionSet.Permissions[0].CanCreateItems = true; permissionSet.Permissions[0].CanCreateItemsSpecified = true; permissionSet.Permissions[0].CanCreateSubFolders = true; permissionSet.Permissions[0].CanCreateSubFoldersSpecified = true; permissionSet.Permissions[0].IsFolderVisible = true; permissionSet.Permissions[0].IsFolderVisibleSpecified = true; permissionSet.Permissions[0].IsFolderContact = true; permissionSet.Permissions[0].IsFolderContactSpecified = true; permissionSet.Permissions[0].IsFolderOwner = true; permissionSet.Permissions[0].IsFolderOwnerSpecified = true; permissionSet.Permissions[0].IsFolderContact = true; permissionSet.Permissions[0].IsFolderContactSpecified = true; permissionSet.Permissions[0].EditItems = new PermissionActionType(); permissionSet.Permissions[0].EditItems = PermissionActionType.All; permissionSet.Permissions[0].EditItemsSpecified = true; permissionSet.Permissions[0].DeleteItems = new PermissionActionType(); permissionSet.Permissions[0].DeleteItems = PermissionActionType.All; permissionSet.Permissions[0].DeleteItemsSpecified = true; permissionSet.Permissions[0].PermissionLevel = new PermissionLevelType(); permissionSet.Permissions[0].PermissionLevel = PermissionLevelType.Custom; permissionSet.Permissions[0].UserId = new UserIdType(); permissionSet.Permissions[0].UserId.PrimarySmtpAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site); // Set PermissionSet for FolderType folder. ((FolderType)createFolderRequest.Folders[0]).PermissionSet = permissionSet; // Set PermissionSet for ContactsType folder. ((ContactsFolderType)createFolderRequest.Folders[2]).PermissionSet = permissionSet; // Set PermissionSet for TasksFolderType folder. ((TasksFolderType)createFolderRequest.Folders[3]).PermissionSet = permissionSet; // Create a new folder. CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest); // Check the response. Common.CheckOperationSuccess(createFolderResponse, 4, this.Site); // Folder ids. FolderIdType[] folderIds = new FolderIdType[createFolderResponse.ResponseMessages.Items.Length]; for (int index = 0; index < createFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, createFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be created successfully!"); // Save folder ids. folderIds[index] = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId; // Save the new created folder's folder id. this.NewCreatedFolderIds.Add(folderIds[index]); } #endregion #region Create a managedfolder CreateManagedFolderRequestType createManagedFolderRequest = this.GetCreateManagedFolderRequest(Common.GetConfigurationPropertyValue("ManagedFolderName1", this.Site)); // Add an email address into request. EmailAddressType mailBox = new EmailAddressType() { EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site) }; createManagedFolderRequest.Mailbox = mailBox; // Create the specified managed folder. CreateManagedFolderResponseType createManagedFolderResponse = this.FOLDAdapter.CreateManagedFolder(createManagedFolderRequest); // Check the response. Common.CheckOperationSuccess(createManagedFolderResponse, 1, this.Site); // Save the new created managed folder's folder id. FolderIdType newFolderId = ((FolderInfoResponseMessageType)createManagedFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId; this.NewCreatedFolderIds.Add(newFolderId); #endregion #region Get the new created folders // GetFolder request. GetFolderType getCreatedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderIds); // Get the new created folder. GetFolderResponseType getCreatedFolderResponse = this.FOLDAdapter.GetFolder(getCreatedFolderRequest); // Check the response. Common.CheckOperationSuccess(getCreatedFolderResponse, 4, this.Site); for (int index = 0; index < getCreatedFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, getCreatedFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder information should be returned!"); } #endregion #region Update the new created folders // UpdateFolder request. UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest( new string[] { "Folder", "CalendarFolder", "ContactsFolder", "TasksFolder" }, new string[] { "SetFolderField", "SetFolderField", "SetFolderField", "SetFolderField" }, folderIds); // Update the folders' properties. UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest); // Check the response. Common.CheckOperationSuccess(updateFolderResponse, 4, this.Site); for (int index = 0; index < updateFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, updateFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!"); } #endregion #region Copy the updated folders to "drafts" folder // Copy the folders into "drafts" folder CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), folderIds); // Copy the folders. CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest); // Check the response. Common.CheckOperationSuccess(copyFolderResponse, 4, this.Site); // Copied Folders' id. FolderIdType[] copiedFolderIds = new FolderIdType[copyFolderResponse.ResponseMessages.Items.Length]; for (int index = 0; index < copyFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, copyFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!"); // Variable to save the folders. copiedFolderIds[index] = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId; // Save the copied folders' folder id. this.NewCreatedFolderIds.Add(copiedFolderIds[index]); } #endregion #region Move the updated folders to "deleteditems" folder // MoveFolder request. MoveFolderType moveFolderRequest = new MoveFolderType(); // Set the request's folderId field. moveFolderRequest.FolderIds = folderIds; // Set the request's destFolderId field. DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType(); toFolderId.Id = DistinguishedFolderIdNameType.deleteditems; moveFolderRequest.ToFolderId = new TargetFolderIdType(); moveFolderRequest.ToFolderId.Item = toFolderId; // Move the specified folders. MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest); // Check the response. Common.CheckOperationSuccess(moveFolderResponse, 4, this.Site); for (int index = 0; index < moveFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, moveFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!"); } #endregion #region Delete all folders // All folder ids. FolderIdType[] allFolderIds = new FolderIdType[folderIds.Length + copiedFolderIds.Length]; for (int index = 0; index < allFolderIds.Length / 2; index++) { allFolderIds[index] = folderIds[index]; allFolderIds[index + folderIds.Length] = copiedFolderIds[index]; } // DeleteFolder request. DeleteFolderType deleteFolderRequest = this.GetDeleteFolderRequest(DisposalType.HardDelete, allFolderIds); // Delete the specified folder. DeleteFolderResponseType deleteFolderResponse = this.FOLDAdapter.DeleteFolder(deleteFolderRequest); // Check the response. Common.CheckOperationSuccess(deleteFolderResponse, 8, this.Site); for (int index = 0; index < deleteFolderResponse.ResponseMessages.Items.Length; index++) { Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, deleteFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!"); } #endregion }
public EmailAddress(string value, EmailAddressType type) : this(value) { this.Type = type; }