public static List<PartnershipStateInfoViewModel> GetAllPartnershipsByOrganizationAccountKey(string organizationAccountKey) { IEnumerable<PartnershipStateInfoDTO> partnerships = OrganizationAccountRepository.GetAllPartnershipsByOrganizationAccountKey(new Guid(organizationAccountKey)); List<PartnershipStateInfoViewModel> result = new List<PartnershipStateInfoViewModel>(); foreach (PartnershipStateInfoDTO item in partnerships) { PartnershipStateInfoViewModel itemview = new PartnershipStateInfoViewModel(); BasicProfileViewModel senderBasicProfile = new BasicProfileViewModel(); senderBasicProfile.ReferenceKey = item.Sender.Key.ToString(); senderBasicProfile.AccountType = AccountType.OrganizationAccount; CompleteProfileViewModel senderCompleteProfile = new CompleteProfileViewModel(); senderCompleteProfile.BasicProfile = senderBasicProfile; BasicProfileViewModel receiverBasicProfile = new BasicProfileViewModel(); receiverBasicProfile.ReferenceKey = item.Receiver.Key.ToString(); receiverBasicProfile.AccountType = AccountType.OrganizationAccount; CompleteProfileViewModel receiverCompleteProfile = new CompleteProfileViewModel(); receiverCompleteProfile.BasicProfile = receiverBasicProfile; //if you are the receiver you only need info from the sender //if you are the sender you only need info from the receiver if (item.Receiver.Key.ToString() == organizationAccountKey) { senderCompleteProfile.BasicProfile.ReferenceKey = item.Sender.Key.ToString(); senderCompleteProfile.BasicProfile.AccountType = AccountType.OrganizationAccount; senderCompleteProfile.FullName = item.Sender.Name; senderCompleteProfile.Description1 = item.Sender.Description; senderCompleteProfile.Description2 = item.Sender.Organization.Name; } else { receiverCompleteProfile.BasicProfile.ReferenceKey = item.Receiver.Key.ToString(); receiverCompleteProfile.BasicProfile.AccountType = AccountType.OrganizationAccount; receiverCompleteProfile.FullName = item.Receiver.Name; receiverCompleteProfile.Description1 = item.Receiver.Description; receiverCompleteProfile.Description2 = item.Receiver.Organization.Name; } itemview.Receiver = receiverCompleteProfile; itemview.Sender = senderCompleteProfile; itemview.PartnershipAction = item.Action; //itemview.ReceiverEmail = item.Receiver.Email; //itemview.SenderEmail = item.Sender.Email; result.Add(itemview); } return result; }
public static PartnershipStateInfoViewModel GetPartnershipBetweenOrganizationAccountsByKeys(string organizationAccountKey1, string organizationAccountKey2) { PartnershipStateInfo partnership = OrganizationAccountRepository.GetPartnershipBetweenOrganizationAccounts(new Guid(organizationAccountKey1), new Guid(organizationAccountKey2)); PartnershipStateInfoViewModel result = new PartnershipStateInfoViewModel(); if (partnership != null) { PartnershipStateInfoViewModel itemview = new PartnershipStateInfoViewModel(); BasicProfileViewModel senderBasicProfile = new BasicProfileViewModel(); senderBasicProfile.ReferenceKey = partnership.Sender.Key.ToString(); senderBasicProfile.AccountType = AccountType.OrganizationAccount; CompleteProfileViewModel senderCompleteProfile = new CompleteProfileViewModel(); senderCompleteProfile.BasicProfile = senderBasicProfile; senderCompleteProfile.FullName = partnership.Sender.Name; senderCompleteProfile.Description1 = partnership.Sender.Description; senderCompleteProfile.Description2 = partnership.Sender.Organization.Name; BasicProfileViewModel receiverBasicProfile = new BasicProfileViewModel(); receiverBasicProfile.ReferenceKey = partnership.Receiver.Key.ToString(); receiverBasicProfile.AccountType = AccountType.UserAccount; CompleteProfileViewModel receiverCompleteProfile = new CompleteProfileViewModel(); receiverCompleteProfile.BasicProfile = receiverBasicProfile; receiverCompleteProfile.FullName = partnership.Receiver.Name; receiverCompleteProfile.Description1 = partnership.Receiver.Description; receiverCompleteProfile.Description2 = partnership.Receiver.Organization.Name; result.ActionDateTime = partnership.ActionDateTime; result.PartnershipAction = partnership.Action; // result.ReceiverEmail = friendship.Receiver.Email; //result.SenderEmail = friendship.Sender.Email; } else { result.PartnershipAction = PartnershipAction.New; } return result; }