Example #1
0
        public void Setup()
        {
            _textModule = TextModuleFactory.Get();

            _command = new AddVersion
            {
                SiteId               = Guid.NewGuid(),
                ModuleId             = _textModule.ModuleId,
                Id                   = _textModule.Id,
                VersionId            = Guid.NewGuid(),
                Content              = "Content",
                Description          = "Description",
                Status               = TextVersionStatus.Published,
                VersionLocalisations = new List <AddVersion.VersionLocalisation>()
                {
                    new AddVersion.VersionLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Content    = "Localised content"
                    }
                }
            };

            _validatorMock = new Mock <IValidator <AddVersion> >();
            _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());

            _textModule.AddVersion(_command, _validatorMock.Object);

            _newVersion = _textModule.TextVersions.FirstOrDefault(x => x.Id == _command.VersionId);

            _event = _textModule.Events.OfType <VersionAdded>().SingleOrDefault();
        }
Example #2
0
        private IList <TextLocalisation> GetVersionLocalisations(VersionAdded cmd)
        {
            var localisations = new List <TextLocalisation>();

            foreach (var localisation in cmd.VersionLocalisations)
            {
                localisations.Add(new TextLocalisation
                {
                    TextVersionId = cmd.VersionId,
                    LanguageId    = localisation.LanguageId,
                    Content       = localisation.Content
                });
            }

            return(localisations);
        }
Example #3
0
        private void Apply(VersionAdded @event)
        {
            var newVersion = new TextVersion(@event.VersionId,
                                             Id,
                                             @event.Content,
                                             @event.Description,
                                             @event.Status,
                                             GetVersionLocalisations(@event));

            TextVersions.Add(newVersion);

            if (newVersion.Status == TextVersionStatus.Published)
            {
                var currentPublishedVersion = TextVersions.FirstOrDefault(x => x.Status == TextVersionStatus.Published);
                currentPublishedVersion?.UnPublish();
            }
        }
Example #4
0
 public void Handle(VersionAdded @event)
 {
     ClearCache(@event.SiteId, @event.ModuleId);
 }
 public Task Handle(VersionAdded @event)
 {
     return(ClearCache(@event.SiteId, @event.ModuleId));
 }