public void Handle(IBulkTotalRatingCreated command) { var totalRatings = _mapper.Map <List <TotalRating> >(command.Data); _demographicRepository.ValidateDemographics(totalRatings.Select(c => c.Demograph).ToList()); _salesAreaRepository.ValidateSalesArea(totalRatings.Select(c => c.SalesArea).ToList()); _totalRatingRepository.AddRange(totalRatings); _totalRatingRepository.SaveChanges(); }
public void Handle(IBulkTotalRatingDeleted command) { foreach (var item in command.Data) { var totalRatings = _totalRatingRepository.Search(item.SalesArea, item.DateTimeFrom, item.DateTimeTo).ToList(); if (totalRatings.Any()) { _totalRatingRepository.DeleteRange(totalRatings.Select(t => t.Id)); } else { _logger.Warn($"No total ratings found for sales area {item.SalesArea} and from {item.DateTimeFrom} to {item.DateTimeTo}"); } } _totalRatingRepository.SaveChanges(); }