BloggingSystem.Services.DataMappers.PostsMapper.CreateNewEntity C# (CSharp) Method

CreateNewEntity() public static method

public static CreateNewEntity ( PostModel postModel, User author, BloggingSystemContext context ) : Post
postModel BloggingSystem.DataTransferObjects.PostModel
author BloggingSystem.Models.User
context BloggingSystem.Data.BloggingSystemContext
return BloggingSystem.Models.Post
        public static Post CreateNewEntity(PostModel postModel, User author, BloggingSystemContext context)
        {
            Post postEntity = new Post()
            {
                Title = postModel.Title,
                Author = author,
                PostDate = DateTime.Now,
                Text = postModel.Text
            };

            foreach (var tagName in postModel.Tags)
            {
                postEntity.Tags.Add(Extensions.CreateOrLoadTag(tagName.ToLower(), context));
            }

            var titleTags = postModel.Title.Split(WordSeparators, StringSplitOptions.RemoveEmptyEntries);
            foreach (var titleTagName in titleTags)
            {
                if (titleTagName.Length > 1)
                {
                    postEntity.Tags.Add(Extensions.CreateOrLoadTag(titleTagName.ToLower(), context));
                }
            }

            return postEntity;
        }