protected override int CreateOrGetOrganizationIdAdditional(int contragentId, Record record) { if (record.OrganizationType != OrgType.ResourceProvider) { return(0); } if (this.publicServiceOrgByContragentIdDict.ContainsKey(contragentId)) { return(this.publicServiceOrgByContragentIdDict[contragentId]); } // create var publicServiceOrg = new PublicServiceOrg { Contragent = new Contragent { Id = contragentId }, OrgStateRole = OrgStateRole.Active, ActivityGroundsTermination = GroundsTermination.NotSet }; PublicServiceOrgRepository.Save(publicServiceOrg); this.publicServiceOrgByContragentIdDict[contragentId] = publicServiceOrg.Id; return(publicServiceOrg.Id); }
protected override void InitDictionaries() { base.InitDictionaries(); this.existingPublicServiceOrgs = PublicServiceOrgRepository.GetAll().Select(x => x.Id).ToList(); this.publicServiceOrgByContragentIdDict = PublicServiceOrgRepository.GetAll() .Select(x => new { ContragentId = x.Contragent.Id, x.Id }) .AsEnumerable() .GroupBy(x => x.ContragentId) .ToDictionary(x => x.Key, x => x.First().Id); // Связь дома и поставщика ресурсов this.publicServiceOrgRo = PublicServiceOrgRealtyObjectRepository.GetAll() .Where(x => x.PublicServiceOrg != null) .Where(x => x.RealityObject != null) .Select(x => new { orgId = x.PublicServiceOrg.Id, roId = x.RealityObject.Id }) .AsEnumerable() .GroupBy(x => x.orgId) .ToDictionary(x => x.Key, x => x.Select(y => y.roId).ToList()); // Договор между домом и поставщиком ресурсов this.publicServiceOrgRoContract = RealObjPublicServiceOrgRepository.GetAll() .Where(x => x.PublicServiceOrg != null) .Where(x => x.RealityObject != null) .Select(x => new { orgId = x.PublicServiceOrg.Id, roId = x.RealityObject.Id }) .AsEnumerable() .GroupBy(x => x.orgId) .ToDictionary(x => x.Key, x => x.Select(y => y.roId).ToList()); }