Example #1
0
File: Tag.cs Project: BionStt/blog
 public Tag(String name,
            String alias = null)
 {
     Name  = name;
     Alias = String.IsNullOrEmpty(alias)
         ? StringToUrlStandard.Convert(name.ToLowerInvariant())
         : alias;
 }
Example #2
0
        public BlogStory ToDomain()
        {
            String slug = null;

            if (String.IsNullOrWhiteSpace(Alias))
            {
                slug = StringToUrlStandard.Convert(Title.Trim());
            }
            else
            {
                Alias = Alias.ToLowerInvariant();
            }

            var story = new BlogStory
            {
                Id             = Id,
                Title          = Title.Trim(),
                Alias          = slug ?? Alias,
                Description    = Description.Trim(),
                SeoDescription = SeoDescription?.Trim(),
                SeoKeywords    = Keywords,
                Content        = Content ?? String.Empty,
                StoryImageUrl  = StoryImageUrl?.Trim(),
                StoryThumbUrl  = StoryThumbUrl?.Trim(),
                CreateDate     = String.IsNullOrWhiteSpace(CreateDate)
                    ? DateTime.Now
                    : DateTime.Parse(CreateDate),
                ModifiedDate = DateTime.Now,
                AccessToken  = AccessToken
            };


            if (!String.IsNullOrEmpty(TagsSelected))
            {
                var tagIds = TagsSelected.GetGuids(',');
                story.BlogStoryTags = tagIds.Select(x => new BlogStoryTag
                {
                    BlogStoryId = story.Id,
                    TagId       = x
                })
                                      .ToList();
            }

            return(story);
        }