Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public void Replace_PageNumber_10()
        {
            TextModule textModule = new TextModule();
            string     result     = textModule.Replace_PageNumber("Page [PageNumber]", 10);

            Assert.AreEqual("Page 10", result);
        }
Exemplo n.º 3
0
        public void Create(TextModule text)
        {
            var textDbEntity = _mapper.Map <TextModuleDbEntity>(text);

            _texts.Add(textDbEntity);
            _context.SaveChanges();
        }
Exemplo n.º 4
0
        public ActionResult Index()
        {
            TextModule tm = GetTextByLabel("Index", CultureUi.TwoLetterISOLanguageName);

            tm.Title = Resources.Language.Home_Index_Title;

            return(View("Index", tm));
        }
Exemplo n.º 5
0
        public ActionResult About()
        {
            TextModule tm = GetTextByLabel("AboutUs", CultureUi.TwoLetterISOLanguageName);

            tm.Title = Resources.Language.Home_AboutUs_Title;

            return(View(tm));
        }
Exemplo n.º 6
0
        public IEnumerable <IEvent> Handle(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            _textModuleRepository.Create(textModule);

            return(textModule.Events);
        }
Exemplo n.º 7
0
        public ICollection<IEvent> Handle(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            _textModuleRepository.Create(textModule);

            return textModule.Events;
        }
Exemplo n.º 8
0
        public async Task <IAggregateRoot> HandleAsync(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            await _textModuleRepository.CreateAsync(textModule);

            return(textModule);
        }
Exemplo n.º 9
0
 public async Task CreateAsync(TextModule text)
 {
     using (var context = _dbContextFactory.Create())
     {
         var textDbEntity = _mapper.Map <TextModuleDbEntity>(text);
         context.TextModules.Add(textDbEntity);
         await context.SaveChangesAsync();
     }
 }
Exemplo n.º 10
0
 public void Create(TextModule text)
 {
     using (var context = _dbContextFactory.Create())
     {
         var textDbEntity = _mapper.Map <TextModuleDbEntity>(text);
         context.TextModules.Add(textDbEntity);
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public void Update(TextModule textModule)
        {
            var textDbEntity = _texts.FirstOrDefault(x => x.Id == textModule.Id);

            textDbEntity.Status = textModule.Status;

            UpdateTextVersions(textModule.TextVersions);

            _context.SaveChanges();
        }
Exemplo n.º 12
0
        public void Update(TextModule textModule)
        {
            using (var context = _dbContextFactory.Create())
            {
                var textDbEntity = context.TextModules.FirstOrDefault(x => x.Id == textModule.Id);

                textDbEntity.Status = textModule.Status;

                UpdateTextVersions(context, textModule.TextVersions);

                context.SaveChanges();
            }
        }
Exemplo n.º 13
0
 public void Setup()
 {
     _command = new CreateTextModule
     {
         SiteId   = Guid.NewGuid(),
         ModuleId = Guid.NewGuid(),
         Id       = Guid.NewGuid(),
         Content  = "Content"
     };
     _validatorMock = new Mock <IValidator <CreateTextModule> >();
     _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());
     _textModule = TextModule.CreateNew(_command, _validatorMock.Object);
     _event      = _textModule.Events.OfType <TextModuleCreated>().SingleOrDefault();
 }
Exemplo n.º 14
0
        public static TextModule Get()
        {
            var siteId = Guid.NewGuid();

            var createCommand = new CreateTextModule
            {
                SiteId   = siteId,
                ModuleId = Guid.NewGuid(),
                Id       = Guid.NewGuid(),
                Content  = "Content"
            };

            var createValidatorMock = new Mock <IValidator <CreateTextModule> >();

            createValidatorMock.Setup(x => x.Validate(createCommand)).Returns(new ValidationResult());

            var textModule = TextModule.CreateNew(createCommand, createValidatorMock.Object);

            var addVersionCommand = new AddVersion
            {
                SiteId               = siteId,
                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"
                    }
                }
            };

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

            textModule.AddVersion(addVersionCommand, _addVersionValidatorMock.Object);

            textModule.Events.Clear();

            return(textModule);
        }
Exemplo n.º 15
0
        private TextModule GetTextByLabel(string label, string culture)
        {
            TextModule tm = null;

            try
            {
                tm = Factory.TextModuleBll.GetByLabel(label, culture);
            }
            catch (Exception ex)
            {
                Logger.Error($"TextModule with `{label}` (culture: {culture}) is not found, use default", ex);
                tm      = new TextModule();
                tm.Text = Resources.Language.SystemMessage_NotFound;
            }

            return(tm);
        }
Exemplo n.º 16
0
        public void ConvertToTextlines_Text()
        {
            Page page = new Page(new Document(), "PAGE", "200mm", "200mm", "rgb", "3mm", 1);

            Font      f  = new Font("FONT", @"C:\Windows\Fonts", "UTF-8", "false", "10pt");
            FontStyle fs = new FontStyle(f, "STYLE", "arial.ttf");

            f.AddStyle(fs);

            Content container = new Content(page);

            object[] paramList = new object[2];
            paramList[0] = container;
            paramList[1] = "TEXT";

            OpenTemplater.Models.Text.Text text = MockRepository.GeneratePartialMock <OpenTemplater.Models.Text.Text>(paramList);

            Paragraph p = new Paragraph(text, "10pt", "left");

            TextElement te = new TextElement(p, "Dit is een hele mooie tekst.", fs, new Unit(10), new Color("blue"));

            p.Add(te);
            p.Add(te);
            p.Add(te);

            text.Add(p);

            TextModule         tm = new TextModule();
            TextlineCollection textlineCollection = tm.ConvertToTextlines(new Unit("35mm"), text);

            // There should be 4 texlines.
            Assert.AreEqual(4, textlineCollection.Count);

            // Each textline should be shorter than 35 milimeters.
            foreach (Textline textline in textlineCollection)
            {
                Assert.AreEqual(true, textline.Width.Points <= new Unit("35mm").Points);
            }

            // The total height of the textlines should be 40mm.
            Assert.AreEqual(40, textlineCollection.Height.Points);
        }
Exemplo n.º 17
0
        public void SetTextlines()
        {
            var textModule = new TextModule();

            TextlineCollection      lines  = textModule.ConvertToTextlines(LayoutContainer.Layout.Width, this);
            TextlineMeasuringOutput output = textModule.SplitTextlines(lines,
                                                                       LayoutContainer.Layout.Height.Points);

            if (Textlines == null)
            {
                Textlines = output.FittingLines;

                LayoutContainer.TryResize(Textlines.Width, Textlines.Height);

                var overflowText = OverflowElement as Text;

                if (overflowText != null)
                {
                    overflowText.Textlines.AddRange(output.NotFittingLines);
                }
            }
        }
Exemplo n.º 18
0
        public async Task <ActionResult> RssFeed(Guid moduleGuid)
        {
            TextModule mod = (TextModule)await ModuleDefinition.LoadAsync(moduleGuid, AllowNone : true);

            if (mod == null || !mod.Feed)
            {
                throw new Error(this.__ResStr("noFeed", "The feed is no longer available"));
            }

            ModuleAction action = await mod.GetAction_RssFeedAwait(mod.ModuleGuid);

            string url = action.GetCompleteUrl();

            SyndicationFeed        feed;
            List <SyndicationItem> items = new List <SyndicationItem>();

            feed = new SyndicationFeed(mod.FeedTitle, mod.FeedSummary,
                                       string.IsNullOrWhiteSpace(mod.FeedMainUrl) ? new Uri(url) : new Uri(Manager.CurrentSite.MakeUrl(mod.FeedMainUrl)),
                                       items);

            action = await mod.GetAction_RssDetailAsync(mod.FeedDetailUrl, mod.ModuleGuid, mod.AnchorId);

            url = action.GetCompleteUrl();
            SyndicationItem sItem = new SyndicationItem(mod.Title, mod.Contents, new Uri(url));

            sItem.PublishDate = mod.FeedPublishDate ?? DateTime.MinValue;
            items.Add(sItem);

            if (mod.FeedImage != null)
            {
                feed.ImageUrl = new Uri(Manager.CurrentSite.MakeUrl(ImageHTML.FormatUrl(YetaWF.Core.Modules.ModuleImageSupport.ImageType, null, mod.FeedImage, CacheBuster: mod.DateUpdated.Ticks.ToString())));
            }
            feed.LastUpdatedTime = mod.FeedUpdateDate ?? DateTime.MinValue;

            return(new RssResult(feed));
        }
 public Mother3ModuleCollection(Mother3RomConfig romConfig)
 {
     Data = new DataModule(romConfig);
     Text = new TextModule(romConfig);
 }