Ejemplo n.º 1
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.º 2
0
 public IEnumerable <RSSettings> FindBySalesAreas(IEnumerable <string> salesAreas) =>
 _mapper.Map <List <RSSettings> >(
     RSSettingsQuery
     .Include(x => x.SalesArea)
     .Where(x => salesAreas.Contains(x.SalesArea.Name)).AsNoTracking(),
     opts => opts.UseEntityCache(_salesAreaByIdCache));
Ejemplo n.º 3
0
 public List <RSSettings> GetAll() =>
 _mapper.Map <List <RSSettings> >(
     RSSettingsQuery.AsNoTracking(),
     opts => opts.UseEntityCache(_salesAreaByIdCache));
Ejemplo n.º 4
0
 public RSSettings Find(string salesArea) =>
 _mapper.Map <RSSettings>(
     RSSettingsQuery
     .Include(x => x.SalesArea)
     .FirstOrDefault(x => x.SalesArea.Name == salesArea),
     opts => opts.UseEntityCache(_salesAreaByIdCache));