Ejemplo n.º 1
0
        public void Add(Schedule item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var isNew = true;

            if (item.Id > 0)
            {
                var entity = GetEntityById(item.Id);
                if (entity != null)
                {
                    _ = _mapper.Map(item, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                    UpdateScheduleBreaks(item, entity);
                    UpdateScheduleProgrammes(item, entity);
                    _ = _dbContext.Update(entity,
                                          post => post.MapTo(item, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
                    isNew = false;
                }
            }

            if (isNew)
            {
                var entity = _mapper.Map <ScheduleEntity>(item, opts => opts.UseEntityCache(_salesAreaByNameCache));
                UpdateScheduleBreaks(item, entity, true);
                UpdateScheduleProgrammes(item, entity, true);
                _ = _dbContext.Add(entity, post => post.MapTo(item, opts => opts.UseEntityCache(_salesAreaByIdCache)),
                                   _mapper);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add or Update method
        /// </summary>
        /// <param name="rsSettings"></param>
        public void Update(RSSettings rsSettings)
        {
            if (rsSettings == null)
            {
                throw new ArgumentNullException(nameof(rsSettings));
            }

            var entity = RSSettingsQuery
                         .FirstOrDefault(x => x.Id == rsSettings.Id);

            if (entity == null)
            {
                _ = _dbContext.Add(
                    _mapper.Map <RSSettingsEntity>(rsSettings,
                                                   opts => opts.UseEntityCache(_salesAreaByNameCache)),
                    post => post.MapTo(
                        rsSettings,
                        opts => opts.UseEntityCache(_salesAreaByIdCache)),
                    _mapper);
            }
            else
            {
                _ = _mapper.Map(rsSettings, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity, post => post.MapTo(rsSettings, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
            }
        }
Ejemplo n.º 3
0
        public void Update(RunType runType)
        {
            var entity = _dbContext
                         .Query <RunTypeEntity>()
                         .Include(o => o.RunTypeAnalysisGroups)
                         .Include(o => o.RunLandmarkScheduleSettings)
                         .FirstOrDefault(o => o.Id == runType.Id);

            if (entity != null)
            {
                if (entity.RunTypeAnalysisGroups != null && entity.RunTypeAnalysisGroups.Any())
                {
                    _dbContext.RemoveRange(entity.RunTypeAnalysisGroups.ToArray());
                    entity.RunTypeAnalysisGroups.Clear();
                }

                if (entity.RunLandmarkScheduleSettings != null)
                {
                    entity.RunLandmarkScheduleSettings.DaysOfWeek = null;
                }

                _mapper.Map(runType, entity);
                _dbContext.Update(entity, post => post.MapTo(runType), _mapper);
            }
        }
        public void AddOrUpdate(IAutoBookDefaultParameters autoBookDefaultParameters)
        {
            var entity = _dbContext.Query <AutoBookDefaultParametersEntity>()
                         .Include(e => e.AgBreak_AgAvals)
                         .Include(e => e.AgBreak_AgPredictions)
                         .Include(e => e.AgBreak_AgRegionalBreaks)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgDayParts).ThenInclude(e => e.AgDayPartLengths)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgDayParts).ThenInclude(e => e.AgTimeSlices)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgLengths).ThenInclude(e => e.AgMultiParts)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgParts)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgPartsLengths)
                         .Include(e => e.AgCampaign_AgCampaignSalesAreas).ThenInclude(e => e.AgStrikeWeights).ThenInclude(e => e.AgStrikeWeightLengths)
                         .Include(e => e.AgCampaign_AgProgrammeList).ThenInclude(e => e.CategoryOrProgramme)
                         .Include(e => e.AgCampaign_AgProgrammeList).ThenInclude(e => e.TimeBands)
                         .Include(e => e.AgHfssDemos)
                         .FirstOrDefault();

            if (entity == null)
            {
                entity = _mapper.Map <AutoBookDefaultParametersEntity>(autoBookDefaultParameters);

                _dbContext.Add(entity, post => post.MapTo(autoBookDefaultParameters), _mapper);
            }
            else
            {
                _mapper.Map(autoBookDefaultParameters, entity);

                _dbContext.Update(entity, post => post.MapTo(autoBookDefaultParameters), _mapper);
            }

            _cachedModel = autoBookDefaultParameters;
        }
Ejemplo n.º 5
0
        public void Add(ScenarioResult scenarioResult)
        {
            var entity = GetQueryWithAllIncludes()
                         .FirstOrDefault(x => x.ScenarioId == scenarioResult.Id);

            if (entity == null)
            {
                _dbContext.Add(_mapper.Map <ScenarioResultEntity>(scenarioResult),
                               post => post.MapTo(scenarioResult), _mapper);
            }
            else
            {
                _mapper.Map(scenarioResult, entity);
                _dbContext.Update(entity, post => post.MapTo(scenarioResult), _mapper);
            }
        }
Ejemplo n.º 6
0
        public void Update(Pass pass)
        {
            var entity = PassQuery.FirstOrDefault(x => x.Id == pass.Id);

            if (entity != null)
            {
                _ = _mapper.Map(
                    pass,
                    entity,
                    opt => opt.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(
                    entity,
                    p => p.MapTo(
                        pass,
                        opt => opt.UseEntityCache(_salesAreaByIdCache)),
                    _mapper);
            }
        }
Ejemplo n.º 7
0
        public void Update(Demographic demographic)
        {
            var entity = _dbContext.Find <Entities.Tenant.Demographic>(demographic.Id);

            if (entity != null)
            {
                _mapper.Map(demographic, entity);
                _dbContext.Update(entity, post => post.MapTo(demographic), _mapper);
            }
        }
Ejemplo n.º 8
0
        public void Update(DeliveryCappingGroup item)
        {
            var entity = _dbContext.Find <Entities.Tenant.DeliveryCappingGroup>(item.Id);

            if (entity != null)
            {
                _mapper.Map(item, entity);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
Ejemplo n.º 9
0
        public void Update(AutopilotRule item)
        {
            var entity = _dbContext.Find <Entities.Tenant.AutopilotRule>(item.Id);

            if (entity != null)
            {
                _mapper.Map(item, entity);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
Ejemplo n.º 10
0
        public void Update(LengthFactor item)
        {
            var entity = _dbContext.Find <Entities.Tenant.LengthFactor>(item.Id);

            if (entity != null)
            {
                _ = _mapper.Map(item, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity);
            }
        }
Ejemplo n.º 11
0
        public void Add(Product item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var entity = ProductQuery.FirstOrDefault(x => x.Uid == item.Uid);

            if (entity == null)
            {
                _dbContext.Add(CreateProductEntity(item), post => post.MapTo(item), _mapper);
            }
            else
            {
                UpdateProductEntity(entity, item);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
Ejemplo n.º 12
0
        public void Update(IndexType indexType)
        {
            var entity = _dbContext.Find <Entities.Tenant.IndexType>(indexType.Id);

            if (entity != null)
            {
                _ = _mapper.Map(indexType, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity, post => post.MapTo(indexType, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
            }
        }
Ejemplo n.º 13
0
        public void Update(FlexibilityLevel item)
        {
            var entity = _dbContext.Find <Entities.Tenant.FlexibilityLevel>(item.Id);

            if (entity != null)
            {
                _mapper.Map(item, entity);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
Ejemplo n.º 14
0
        public EfficiencySettings UpdateDefault(EfficiencySettings settings)
        {
            var settingsToSave = settings.Id == default ?
                                 GetDefault().FulfillFrom(settings) : settings;
            var entity = _dbContext.Find <Entities.Tenant.EfficiencySettings>(settingsToSave.Id);

            _mapper.Map(settingsToSave, entity);
            _dbContext.Update(entity, post => post.MapTo(settingsToSave), _mapper);
            return(settingsToSave);
        }
Ejemplo n.º 15
0
        public void Update(SpotPlacement spotPlacement)
        {
            var entity = _dbContext.Find <Entities.Tenant.SpotPlacement>(
                (spotPlacement ?? throw new ArgumentNullException(nameof(spotPlacement))).Id);

            if (entity != null)
            {
                _mapper.Map(spotPlacement, entity);
                _dbContext.Update(entity, post => post.MapTo(spotPlacement), _mapper);
            }
        }
Ejemplo n.º 16
0
        public void Update(SmoothConfiguration smoothConfiguration)
        {
            var entity = _dbContext.Query <SmoothConfigurationEntity>()
                         .FirstOrDefault(x => x.Id == smoothConfiguration.Id);

            if (entity != null)
            {
                _ = _mapper.Map(smoothConfiguration, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity, post => post.MapTo(smoothConfiguration, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
            }
        }
Ejemplo n.º 17
0
        public ISRGlobalSettings Update(ISRGlobalSettings settings)
        {
            var existingSettings = _dbContext.Query <ISRGlobalSettingsEntity>().SingleOrDefault() ??
                                   new ISRGlobalSettingsEntity();

            _mapper.Map(settings, existingSettings);

            _dbContext.Update(existingSettings, post => post.MapTo(settings), _mapper);

            return(settings);
        }
Ejemplo n.º 18
0
        public void Update(CampaignSettings item)
        {
            var entity = _dbContext.Query <CampaignSettingsEntity>()
                         .FirstOrDefault(cs => cs.Id == item.Id);

            if (entity != null)
            {
                _mapper.Map(item, entity);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
Ejemplo n.º 19
0
        public void Update(ProgrammeClassification programmeClassification)
        {
            var entity = _dbContext.Query <Entities.Tenant.ProgrammeClassification>()
                         .FirstOrDefault(e => e.Uid == programmeClassification.Uid);

            if (entity != null)
            {
                _mapper.Map(programmeClassification, entity);
                _dbContext.Update(entity, post => post.MapTo(programmeClassification), _mapper);
            }
        }
Ejemplo n.º 20
0
        public void Update(EmailAuditEventSettings item)
        {
            var entity = _dbContext.Query <EmailAuditEventSettingsEntity>()
                         .FirstOrDefault(e => e.EventTypeId == item.EventTypeId);

            if (entity != null)
            {
                _mapper.Map(item, entity);
                _dbContext.Update(entity, post => post.MapTo(item), _mapper);
            }
        }
        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);
        }
Ejemplo n.º 22
0
        public void Update(Domain.Shared.SalesAreas.SalesArea salesArea)
        {
            var entity = _dbContext.Find <Entities.Tenant.SalesAreas.SalesArea>(new object[] { salesArea.Id },
                                                                                find => find.IncludeCollection(sa => sa.ChannelGroups).IncludeCollection(sa => sa.Holidays));

            if (entity != null)
            {
                _mapper.Map(salesArea, entity);
                _dbContext.Update(entity, post => post.MapTo(salesArea), _mapper);
                _sequenceRebuilder.Execute(_dbContext, e => e.CustomId);
            }
        }
Ejemplo n.º 23
0
        public void Update(BookingPositionGroup bookingPositionGroup)
        {
            var entity = _dbContext.Query <BookingPositionGroupEntity>()
                         .Include(g => g.PositionGroupAssociations)
                         .FirstOrDefault(x => x.Id == bookingPositionGroup.Id);

            if (entity != null)
            {
                _mapper.Map(bookingPositionGroup, entity);
                _dbContext.Update(entity, post => post.MapTo(bookingPositionGroup), _mapper);
            }
        }
Ejemplo n.º 24
0
        public void Update(Facility facility)
        {
            var existingEntity = _dbContext.Find <FacilityEntity>(facility.Id);

            if (existingEntity is null)
            {
                return;
            }

            _mapper.Map(facility, existingEntity);
            _dbContext.Update(existingEntity, post => post.MapTo(facility), _mapper);
        }
Ejemplo n.º 25
0
        public void Update(AnalysisGroup analysisGroup)
        {
            var entity = _dbContext
                         .Query <Entities.Tenant.AnalysisGroups.AnalysisGroup>()
                         .FirstOrDefault(x => x.Id == analysisGroup.Id);

            if (entity != null)
            {
                _mapper.Map(analysisGroup, entity);
                _dbContext.Update(entity, post => post.MapTo(analysisGroup), _mapper);
            }
        }
Ejemplo n.º 26
0
        public void Update(Scenario scenario)
        {
            var entity = GetScenarioQueryWithAllIncludes().FirstOrDefault(e => e.Id == scenario.Id);

            if (entity != null)
            {
                _mapper.Map(scenario, entity);
                ApplyPassesOrder(entity.PassReferences);

                _dbContext.Update(entity, post => post.MapTo(scenario), _mapper);
            }
        }
Ejemplo n.º 27
0
        public void Update(Universe universe)
        {
            var entity = _dbContext.Find <Entities.Tenant.Universe>(
                (universe ?? throw new ArgumentNullException(nameof(universe))).Id);

            if (entity != null)
            {
                _ = _mapper.Map(universe, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity,
                                      post => post.MapTo(universe, opts => opts.UseEntityCache(_salesAreaByIdCache)), _mapper);
            }
        }
Ejemplo n.º 28
0
        public void Update(Spot item)
        {
            var entity = _dbContext.Query <Entities.Tenant.Spot>()
                         .FirstOrDefault(e => e.Uid == item.Uid);

            if (entity != null)
            {
                _ = _mapper.Map(item, entity, opts => opts.UseEntityCache(_salesAreaByNameCache));
                _ = _dbContext.Update(entity,
                                      post => post.MapTo(item, opts => opts.UseEntityCache(_salesAreaByIdCache)),
                                      _mapper);
            }
        }
Ejemplo n.º 29
0
        public void Update(AutoBook autoBook)
        {
            var autoBookId = AutoBookProfile.AutoBookCollectionIdToEntityAutoBookId(autoBook.Id);

            var entity = _dbContext.Query <Entities.Tenant.AutoBookApi.AutoBook>()
                         .Include(x => x.Task)
                         .FirstOrDefault(x => x.AutoBookId == autoBookId);

            if (entity != null)
            {
                _mapper.Map(autoBook, entity);
                _dbContext.Update(entity, post => post.MapTo(autoBook), _mapper);
            }
        }
Ejemplo n.º 30
0
        public void Add(Channel channel)
        {
            var entity = _dbContext.Find <Entities.Tenant.Channel>(channel.Id);

            if (entity == null)
            {
                _dbContext.Add(_mapper.Map <Entities.Tenant.Channel>(channel), post => post.MapTo(channel), _mapper);
            }
            else
            {
                _mapper.Map(channel, entity);
                _dbContext.Update(entity, post => post.MapTo(channel), _mapper);
            }
        }