/// <summary>
        /// Handles the command recieved with Masstransit 
        /// </summary>
        /// <param name="command">this is bulk model of demographics that need to be updated in database</param>
        public override void Handle(IBulkDemographicCreatedOrUpdated command)
        {
            var demographicEntities = _mapper.Map<List<Demographic>>(command.Data);
            var existedDemographics = _demographicsRepository.GetByExternalRef(command.Data.Select(c => c.ExternalRef).ToList());
            var demographics = new List<Demographic>();

            foreach (var demographic in demographicEntities)
            {
                var demographicToUpdate = existedDemographics.FirstOrDefault(c => c.ExternalRef == demographic.ExternalRef);
                if (demographicToUpdate == null)
                {
                    demographics.Add(demographic);
                }
                else
                {
                    demographicToUpdate.Update(demographic.Name, demographic.ShortName, demographic.DisplayOrder, demographic.Gameplan);
                    demographics.Add(demographicToUpdate);
                }
            }

            _demographicsRepository.InsertOrUpdate(demographics);
            _demographicsRepository.SaveChanges();
        }