Ejemplo n.º 1
0
        public override void Handle(IClashUpdated command)
        {
            var clash = _clashRepository.CheckClashByExternalRef(command.Externalref);

            clash.ParentExternalidentifier = command.ParentExternalidentifier;
            clash.Description = command.Description;
            clash.DefaultPeakExposureCount    = command.ExposureCount;
            clash.DefaultOffPeakExposureCount = command.ExposureCount;
            clash.Differences = _mapper.Map <List <ClashDifference> >(command.Differences);

            foreach (var difference in clash.Differences)
            {
                difference.TimeAndDow = new GamePlan.Domain.Generic.Types.TimeAndDowAPI
                {
                    StartTime = new TimeSpan(6, 0, 0),
                    EndTime   = new TimeSpan(5, 59, 59)
                };
                difference.TimeAndDow.SetDaysOfWeek("1111111");
            }

            if (!string.IsNullOrWhiteSpace(clash.ParentExternalidentifier))
            {
                _clashRepository.CheckClashParents(new[] { clash });
            }

            _clashRepository.Add(clash);
            _clashRepository.SaveChanges();
        }