public IQueryable <object> GetMatchFor(string producerCode) { var trimmed = _producerCodeService.TrimCode(producerCode); return(_dbContext.SupplierPriceItems.Include(x => x.PartsSupplier) .Where(x => x.ProducerCodeTrimmed == producerCode) .Select(x => new { Name = x.Name, SupplierName = x.PartsSupplier.Name, SupplierId = x.PartsSupplierId })); }
public async Task CreateCatalogItem(ItemForModeration item) { var newCatalogItem = new ProducerCatalogItem { EnName = item.EnName, RuName = item.RuName, ProducerId = item.ProducerId, ProducerCode = item.ProducerCode, ProducerCodeTrimmed = _producerCodeService.TrimCode(item.ProducerCode), SeoParameterId = item.SeoParameterId }; await _dbContext.AddAsync(newCatalogItem); await _dbContext.SaveChangesAsync(); }
public async Task IncrementFor(string producerCode, string producerName) { var code = _producerCodeService.TrimCode(producerCode); var items = this._catalogItemRepository.GetMatch(producerCode, producerName) .Where(x => x.ProducerCodeTrimmed == code).ToList(); if (items.Any()) { var list = new List <CatalogItemStatistic> (); foreach (var item in items) { list.Add(new CatalogItemStatistic { CatalogItem = item, }); } await this._catalogItemStatisticRepository.AddRange(list); } }