public void Update(BRSConfigurationTemplate item)
 {
     lock (_session)
     {
         _session.Store(item);
     }
 }
        public void Apply()
        {
            foreach (var tenantConnectionString in _tenantConnectionStrings)
            {
                using (var documentStore = DocumentStoreFactory.CreateStore(tenantConnectionString, null))
                    using (var session = documentStore.OpenSession())
                    {
                        var kpiPriorities = new List <KPIPriority>
                        {
                            new KPIPriority {
                                Id = 1, Name = "Exclude", WeightingFactor = 0
                            },
                            new KPIPriority {
                                Id = 2, Name = "Extremely Low", WeightingFactor = 0.3
                            },
                            new KPIPriority {
                                Id = 3, Name = "Low", WeightingFactor = 0.7
                            },
                            new KPIPriority {
                                Id = 4, Name = "Medium", WeightingFactor = 1
                            },
                            new KPIPriority {
                                Id = 5, Name = "High", WeightingFactor = 1.3
                            },
                            new KPIPriority {
                                Id = 6, Name = "Extremely High", WeightingFactor = 1.7
                            },
                        };
                        using (var bulkInsert = session.Advanced.DocumentStore.BulkInsert(null, new BulkInsertOptions()
                        {
                            OverwriteExisting = true
                        }))
                        {
                            kpiPriorities.ToList().ForEach(item => bulkInsert.Store(item));
                        }

                        var template = new BRSConfigurationTemplate
                        {
                            Name              = "Default template",
                            IsDefault         = true,
                            LastModified      = DateTime.UtcNow,
                            KPIConfigurations = BRSHelper.KPIs.Select(kpi => new BRSConfigurationForKPI
                            {
                                KPIName    = kpi,
                                PriorityId = 4
                            }).ToList()
                        };

                        session.Store(template);
                        session.SaveChanges();
                    }
            }
        }
        public void Update(BRSConfigurationTemplate item)
        {
            var entity = _dbContext.Find <Entities.Tenant.BRS.BRSConfigurationTemplate>(new object[] { item.Id }, find => find.IncludeCollection(x => x.KPIConfigurations));

            if (entity is null)
            {
                return;
            }

            _mapper.Map(item, entity);
            _dbContext.Update(entity, post => post.MapTo(item), _mapper);
        }
 public void Add(BRSConfigurationTemplate item) => _dbContext.Add(_mapper.Map <Entities.Tenant.BRS.BRSConfigurationTemplate>(item), post => post.MapTo(item), _mapper);