private void InitEcoSecondStage(SIN sin) { if ((sin.Passport.MetatypeId ?? 0) > 5) { sin.EVersion = "4"; SaveContext(); return; } var joinchacter = Get <JoinCharacter>(jc => jc.CharacterId == sin.CharacterId); var fields = GetList <JoinFieldValue>(jfv => jfv.JoinCharacterId == joinchacter.Id, jfv => jfv.JoinField); var insurance = fields.FirstOrDefault(f => f.JoinField.Name == "Страховка"); var lifestyle = Lifestyles.Wood; CorporationWallet citizen; ShopWallet shop; Sku sku; if (insurance != null) { lifestyle = BillingHelper.GetLifestyleFromJoin(insurance.Value); } sin.Wallet.Balance = GetStartBalance(lifestyle); var ls = (int)lifestyle; var pt = ProductTypeEnum.Insurance.ToString(); if (lifestyle == Lifestyles.Wood) { citizen = Get <CorporationWallet>(c => c.Alias == "Omnistar"); if (citizen == null) { throw new BillingNotFoundException("Гражданство при инициализации не найдено"); } shop = Get <ShopWallet>(s => s.Name == "МЧС"); } else { if (lifestyle == Lifestyles.Iridium) { sin.Wallet.IsIrridium = true; } else { sin.Wallet.IsIrridium = false; } if (sin.Passport.Citizenship == "Россия") { citizen = Get <CorporationWallet>(c => c.Alias == "Россия"); shop = Get <ShopWallet>(s => s.Name == "МЧС"); } else { citizen = Get <CorporationWallet>(c => c.Alias == "Zurich-Orbital"); shop = Get <ShopWallet>(s => s.Name == "CrashCart"); } if (citizen == null) { throw new BillingNotFoundException("Гражданство при инициализации не найдено"); } if (shop == null) { throw new BillingNotFoundException("Продавец страховки при инициализации не найден"); } } sku = Get <Sku>(s => s.CorporationId == citizen.Id && s.Nomenklatura.Specialisation.ProductType.Alias == pt && s.Nomenklatura.Lifestyle == ls, s => s.Nomenklatura.Specialisation.ProductType, s => s.Corporation); if (sku == null) { throw new BillingNotFoundException("Страховка при инициализации не найдена"); } if (shop == null) { throw new BillingNotFoundException("Магазин стартовой страховки не найден"); } var price = CreateNewPrice(sku, shop, sin); var renta = CreateRenta(sin.Character.Model, price.Id, 0, 1); sin.EVersion = "4"; SaveContext(); }