public DataManager() { cont = new ModelContainer1(); UserRepo = new UserRepository(cont); MetRepo = new MeterRepository(cont); InstMetRepo = new InstMeterRepository(cont); ParRepo = new ParametrRepository(cont); TypeRepo = new TypeRepository(cont); ReadRepo = new ReadingRepository(cont); TarRepo = new TariffRepository(cont); TimeSpanRepo = new TimeSpanRepository(cont); DocRepo = new DocumentRepository(cont); }
public TariffController(ApplicationDbContext ctx, TariffRepository tariffRepo) { context = ctx; TariffRepo = tariffRepo; }
public async Task SeedAsync(DataSeedContext context) { if (context.TenantId == null) { return; } var videoFeature = new Feature(GuidGenerator.Create(), "Видеозвонки", "video") { TenantId = context.TenantId }; var audioFeature = new Feature(GuidGenerator.Create(), "Аудиозвонки", "audio") { TenantId = context.TenantId }; var messagesFeature = new Feature(GuidGenerator.Create(), "Сообщения", "messages") { TenantId = context.TenantId }; var historyFeature = new Feature(GuidGenerator.Create(), "История", "history") { TenantId = context.TenantId }; var usersFeature = new Feature(GuidGenerator.Create(), "Пользователи", "users") { TenantId = context.TenantId }; var projectsFeature = new Feature(GuidGenerator.Create(), "Проекты", "projects") { TenantId = context.TenantId }; var ssoFeature = new Feature(GuidGenerator.Create(), "SSO", "sso") { TenantId = context.TenantId }; await FeatureRepository.InsertAsync(videoFeature, true); await FeatureRepository.InsertAsync(audioFeature, true); await FeatureRepository.InsertAsync(messagesFeature, true); await FeatureRepository.InsertAsync(historyFeature, true); await FeatureRepository.InsertAsync(usersFeature, true); await FeatureRepository.InsertAsync(projectsFeature, true); await FeatureRepository.InsertAsync(ssoFeature, true); var basicTariff = new Tariff(GuidGenerator.Create(), "Базовый") { TenantId = context.TenantId }; var mediumTariff = new Tariff(GuidGenerator.Create(), "Обычный") { TenantId = context.TenantId }; basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, videoFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, audioFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, messagesFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, historyFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, usersFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, projectsFeature, 2) { TenantId = context.TenantId }); basicTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, ssoFeature, 2) { TenantId = context.TenantId }); // -- mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, videoFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, audioFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, messagesFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, historyFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, usersFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, projectsFeature, 10) { TenantId = context.TenantId }); mediumTariff.TariffFeatures.Add(new TariffFeature(GuidGenerator.Create(), basicTariff, ssoFeature, 10) { TenantId = context.TenantId }); await TariffRepository.InsertAsync(basicTariff, true); await TariffRepository.InsertAsync(mediumTariff, true); }