public void should_create_ContentElement_based_on_Dto()
        {
            var dto = new ContentElementDto()
            {
                ContentElementId = 1,
                ContentType = ContentType.Text,
                DefaultLanguage = "en",
                TextContents = new List<TextContentDto>
                {
                    new TextContentDto()
                    {
                        ContentElementId = 1,
                        ContentStatus = ContentStatus.Complete,
                        Language = "en",
                        TextContentId = 2,
                        Value = "test"
                    }
                }
            };

            ContentElement ce = factory.Create(dto);

            ce.ContentElementId.Should().Be(1);
            ce.ContentType.Should().Be(ContentType.Text);
            ce.DefaultLanguage.LanguageId.Should().Be("en");
        }
예제 #2
0
 public TextContentDto(TextContent tc, ContentElementDto ce)
 {
     TextContentId = tc.ContentValueId;
     ContentElementId = ce.ContentElementId;
     ContentStatus = tc.Status;
     Value = tc.Value;
     Language = tc.Language.LanguageId;
 }
예제 #3
0
 public TextContentDto(TextContent tc, ContentElementDto ce)
 {
     TextContentId    = tc.ContentValueId;
     ContentElementId = ce.ContentElementId;
     ContentStatus    = tc.Status;
     Value            = tc.Value;
     Language         = tc.Language.LanguageId;
 }
예제 #4
0
        public void InsertNewContentElement(ContentElementDto contentElement)
        {
            var repo = new ContentElementRepository();
            try
            {
                var ce = new ContentDomain.Factories.ContentElementFactory().Create(contentElement);
                repo.Insert(ce);
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is ArgumentNullException)
                    throw new DomainException("Error occured when trying to insert ContentElement: " + ex.Message);

                throw;
            }
        }
예제 #5
0
        public void UpdateContentElement(int contentElementId, ContentElementDto contentElement)
        {
            var repo = new ContentElementRepository();
            try
            {
                var factory = new ContentDomain.Factories.ContentElementFactory();
                var ce = factory.Create(contentElement);
                var originalContentElement = repo.Get(contentElementId);
                foreach (var value in contentElement.TextContents)
                {
                    originalContentElement.UpdateValue(factory.CreateTextContent(value));
                }

                repo.Update(ce);
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is ArgumentNullException)
                    throw new DomainException("Error occured when trying to insert ContentElement: " + ex.Message);

                throw;
            }
        }