Пример #1
0
        private Olma.PartnerDirectory FindOrAddDirectoryByType(Olma.PartnerDirectoryType partnerDirectoryType, string directoryName)
        {
            var directory = _olmaPartnerDirectoryRepo
                            .FindByCondition(d => d.Type == Olma.PartnerDirectoryType.ExpressCodeImportCustom)
                            .Include(d => d.CustomerPartnerDirectoryAccesses)
                            .Include(d => d.OrganizationPartnerDirectories)
                            .SingleOrDefault();

            // Create if does not exist
            if (directory != null)
            {
                return(directory);
            }
            if (string.IsNullOrWhiteSpace(directoryName))
            {
                directoryName = "Default Directory";
            }
            directory = new Olma.PartnerDirectory()
            {
                Type = partnerDirectoryType,
                Name = directoryName,
                CustomerPartnerDirectoryAccesses = new List <Olma.CustomerPartnerDirectoryAccess>(),
                OrganizationPartnerDirectories   = new List <Olma.OrganizationPartnerDirectory>()
                {
                    new Olma.OrganizationPartnerDirectory()
                    {
                        OrganizationId = AuthData.GetOrganizationId()
                    }
                }
            };
            _olmaPartnerDirectoryRepo.Create(directory);
            _olmaCustomerPartnerRepo.Save();
            return(directory);
        }