public void Update(RSSettings rsSettings)
 {
     lock (_session)
     {
         _session.Store(rsSettings);
     }
 }
Beispiel #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);
            }
        }
 public void Delete(string salesArea)
 {
     lock (_session)
     {
         RSSettings rsSettings = _session.Query <RSSettings>().Where(s => s.SalesArea == salesArea).FirstOrDefault();
         if (rsSettings != null)
         {
             _session.Delete <RSSettings>(rsSettings);
         }
     }
 }