/// <summary> /// Creates mailbox model instance. /// </summary> /// <param name="entity">Mailbox entity.</param> /// <param name="mailServers">Mail servers models collection.</param> /// <param name="folders">Mail folders collection.</param> /// <returns><see cref="Mailbox"/> instance.</returns> private Mailbox CreateMailbox(Entity entity, IEnumerable <MailServer> mailServers, IEnumerable <MailboxFolder> folders) { var mailServerId = entity.GetTypedColumnValue <Guid>("MailServerId"); var mailboxFolders = folders.Where(f => f.MailboxId.Equals(entity.PrimaryColumnValue)); var mailServer = mailServers.First(ms => ms.Id.Equals(mailServerId)); var mailbox = new Mailbox(entity, mailServer); mailbox.AddFolders(mailboxFolders); return(mailbox); }