public OrganizationModel GetCurrentUserOrganization()
        {
            var currentOrganization = _organizationDomainService.GetCurrentUserOrganizationEntity();

            if (currentOrganization == null)
            {
                return(null);
            }

            if (currentOrganization.ParentOrganizationId == Guid.Empty)
            {
                return(new OrganizationModel(currentOrganization));
            }

            var parentOrganization =
                _organizationDomainService.GetOrganizationEntityById(currentOrganization.ParentOrganizationId.ToString());

            return(new OrganizationModel(currentOrganization)
            {
                ParentOrganization = new OrganizationModel(parentOrganization)
            });
        }
Exemple #2
0
        public List <ContactViewModel> GetContactsForCurrentOrganization()
        {
            var currentOrganization = _organizationDomainService.GetCurrentUserOrganizationEntity();

            if (currentOrganization == null)
            {
                return(new List <ContactViewModel>());
            }

            var organizationUsers = _customerDomainService.GetContactsForOrganization(currentOrganization.OrganizationEntity);

            if (currentOrganization.SubOrganizations.Count > 0)
            {
                foreach (var subOrg in currentOrganization.SubOrganizations)
                {
                    var contacts = _customerDomainService.GetContactsForOrganization(subOrg.OrganizationEntity);
                    organizationUsers.AddRange(contacts);
                }
            }

            return(organizationUsers.Select(user => new ContactViewModel(user)).ToList());
        }